Documentation
¶
Overview ¶
Package query_cache is a cache used to store query results.
Each plugin process has a single QueryCache instance which stores the data for all connections
Index ¶
- Constants
- func IsCacheMiss(err error) bool
- func NewPendingIndexItem(req *CacheRequest) *pendingIndexItem
- type CacheData
- type CacheMissError
- type CacheRequest
- type CacheStats
- type IndexBucket
- type IndexItem
- type QueryCache
- func (c *QueryCache) AbortSet(ctx context.Context, callId string, err error)
- func (c *QueryCache) ClearForConnection(ctx context.Context, connectionName string)
- func (c *QueryCache) EndSet(ctx context.Context, callId string) (err error)
- func (c *QueryCache) Get(ctx context.Context, req *CacheRequest, streamRowFunc func(row *sdkproto.Row)) error
- func (c *QueryCache) IterateSet(ctx context.Context, row *sdkproto.Row, callId string) error
- func (c *QueryCache) StartSet(_ context.Context, req *CacheRequest)
Constants ¶
const ( // Key column CacheMatch values CacheMatchSubset = "subset" CacheMatchExact = "exact" )
Variables ¶
This section is empty.
Functions ¶
func IsCacheMiss ¶
func NewPendingIndexItem ¶
func NewPendingIndexItem(req *CacheRequest) *pendingIndexItem
Types ¶
type CacheData ¶
type CacheData interface {
proto.Message
*sdkproto.QueryResult | *sdkproto.IndexBucket
}
type CacheMissError ¶
type CacheMissError struct{}
func (CacheMissError) Error ¶
func (CacheMissError) Error() string
type CacheRequest ¶
type CacheStats ¶
type IndexBucket ¶
type IndexBucket struct {
Items []*IndexItem
}
IndexBucket contains index items for all cache results for a given table and qual set
func IndexBucketfromProto ¶
func IndexBucketfromProto(b *proto.IndexBucket) *IndexBucket
func (*IndexBucket) Append ¶
func (b *IndexBucket) Append(item *IndexItem) *IndexBucket
func (*IndexBucket) AsProto ¶
func (b *IndexBucket) AsProto() *proto.IndexBucket
func (*IndexBucket) Get ¶
func (b *IndexBucket) Get(req *CacheRequest, keyColumns map[string]*proto.KeyColumn) *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
InsertionTime time.Time
PageCount int64
}
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(req *CacheRequest) *IndexItem
func (IndexItem) SatisfiesColumns ¶
SatisfiesColumns returns whether this index item satisfies the given columns used when determining whether this IndexItem satisfies a cache reques
func (IndexItem) SatisfiesLimit ¶
SatisfiesLimit returns whether this index item satisfies the given limit used when determining whether this IndexItem satisfies a cache reques
func (IndexItem) SatisfiesQuals ¶
func (i IndexItem) SatisfiesQuals(checkQualMap map[string]*proto.Quals, keyColumns map[string]*proto.KeyColumn) 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
NOTE: some columns cannot use this subset logic. Generally this applies to columns which represent a filter which is executed server side to filter the data returned. In this case, we only identify a cache hit if the cached data has the _same_ value for the given colummn
NOTE: if the IndexItem has a limit, the quals must be IDENTICAL (ignoring ordering)
func (IndexItem) SatisfiesTtl ¶
SatisfiesTtl does this index item satisfy the ttl requirement
type QueryCache ¶
type QueryCache struct {
Stats *CacheStats
// map of connection name to plugin schema
PluginSchemaMap map[string]*grpc.PluginSchema
// contains filtered or unexported fields
}
func NewQueryCache ¶
func NewQueryCache(pluginName string, pluginSchemaMap map[string]*grpc.PluginSchema, maxCacheStorageMb int) (*QueryCache, error)
func (*QueryCache) AbortSet ¶
func (c *QueryCache) AbortSet(ctx context.Context, callId string, err error)
func (*QueryCache) ClearForConnection ¶
func (c *QueryCache) ClearForConnection(ctx context.Context, connectionName string)
ClearForConnection removes all cache entries for the given connection
func (*QueryCache) EndSet ¶
func (c *QueryCache) EndSet(ctx context.Context, callId string) (err error)
func (*QueryCache) Get ¶
func (c *QueryCache) Get(ctx context.Context, req *CacheRequest, streamRowFunc func(row *sdkproto.Row)) error
func (*QueryCache) IterateSet ¶
func (*QueryCache) StartSet ¶
func (c *QueryCache) StartSet(_ context.Context, req *CacheRequest)