cache

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPendingIndexItem

func NewPendingIndexItem(columns []string, key string, limit int64) *pendingIndexItem

Types

type CacheStats

type CacheStats struct {
	// keep count of hits and misses
	Hits   int
	Misses int
}

type IndexBucket

type IndexBucket struct {
	Items []*IndexItem
}

IndexBucket contains index items for all cache results for a given table and qual set

func (*IndexBucket) Append

func (b *IndexBucket) Append(item *IndexItem) *IndexBucket

func (*IndexBucket) Get

func (b *IndexBucket) Get(qualMap map[string]*proto.Quals, columns []string, limit int64) *IndexItem

Get finds an index item which satisfies all columns

type IndexItem

type IndexItem struct {
	Columns []string
	Key     string
	Limit   int64
	Quals   map[string]*proto.Quals
}

IndexItem stores the columns and cached index for a single cached query result note - this index item it tied to a specific table and set of quals

func NewIndexItem

func NewIndexItem(columns []string, key string, limit int64, quals map[string]*proto.Quals) *IndexItem

func (IndexItem) SatisfiesColumns

func (i IndexItem) SatisfiesColumns(columns []string) bool

SatisfiesColumns returns whether this index item satisfies the given columns used when determining whether this IndexItem satisfies a cache reques

func (IndexItem) SatisfiesLimit

func (i IndexItem) SatisfiesLimit(limit int64) bool

SatisfiesLimit returns whether this index item satisfies the given limit used when determining whether this IndexItem satisfies a cache reques

func (IndexItem) SatisfiesQuals added in v1.8.1

func (i IndexItem) SatisfiesQuals(checkQualMap map[string]*proto.Quals) bool

SatisfiesQuals does this index item satisfy the check quals all data returned by check quals is returned by index quals

i.e. check quals must be a 'subset' of index quals
eg
   our quals [], check quals [id="1"] 				-> SATISFIED
   our quals [id="1"], check quals [id="1"] 		-> SATISFIED
   our quals [id="1"], check quals [id="1", foo=2] -> SATISFIED
   our quals [id="1", foo=2], check quals [id="1"] -> NOT SATISFIED

type QueryCache

type QueryCache struct {
	Stats *CacheStats

	PluginSchema map[string]*proto.TableSchema
	// contains filtered or unexported fields
}

func NewQueryCache

func NewQueryCache(connectionName string, pluginSchema map[string]*proto.TableSchema) (*QueryCache, error)

func (*QueryCache) CancelPendingItem

func (c *QueryCache) CancelPendingItem(table string, qualMap map[string]*proto.Quals, columns []string, limit int64)

CancelPendingItem cancels a pending item - called when an execute call fails for any reason

func (*QueryCache) Clear

func (c *QueryCache) Clear()

func (*QueryCache) Get

func (c *QueryCache) Get(ctx context.Context, table string, qualMap map[string]*proto.Quals, columns []string, limit, clientTTLSeconds int64) *QueryCacheResult

func (*QueryCache) Set

func (c *QueryCache) Set(table string, qualMap map[string]*proto.Quals, columns []string, limit int64, result *QueryCacheResult) (res bool)

type QueryCacheResult

type QueryCacheResult struct {
	Rows          []*proto.Row
	InsertionTime time.Time
}

func (*QueryCacheResult) Append

func (q *QueryCacheResult) Append(row *proto.Row)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL