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
- type CacheData
- type CacheMissError
- type CacheRequest
- type CacheStats
- type IndexBucket
- type IndexItem
- type NoSubscribersError
- type QueryCache
- func (c *QueryCache) AbortSet(ctx context.Context, callId string, err error)
- func (c *QueryCache) ClearForConnection(ctx context.Context, connectionName string) error
- func (c *QueryCache) EndSet(ctx context.Context, callId string) error
- func (c *QueryCache) Get(ctx context.Context, req *CacheRequest, ...) error
- func (c *QueryCache) IterateSet(ctx context.Context, row *sdkproto.Row, callId string) error
- func (c *QueryCache) SetPluginSchemaMap(schemaMap map[string]*grpc.PluginSchema)
- type QueryCacheOptions
Constants ¶
const ( // Key column CacheMatch values CacheMatchSubset = "subset" CacheMatchExact = "exact" )
const ( // cache has a default hard TTL limit of 24 hours DefaultMaxTtl = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func IsCacheMiss ¶
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 connection
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
SortOrder []*proto.SortColumn
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
type NoSubscribersError ¶
type NoSubscribersError struct{}
func (NoSubscribersError) Error ¶
func (NoSubscribersError) Error() string
type QueryCache ¶
type QueryCache struct {
Stats *CacheStats
Enabled bool
// contains filtered or unexported fields
}
func NewQueryCache ¶
func NewQueryCache(pluginName string, pluginSchemaMap map[string]*grpc.PluginSchema, opts *QueryCacheOptions) (*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) error
ClearForConnection removes all cache entries for the given connection
func (*QueryCache) EndSet ¶
func (c *QueryCache) EndSet(ctx context.Context, callId string) error
EndSet writes the last page of the scan, and adds the result to the cache index. Then it waits for the scan's readers to finish. If the query that started the scan could not read every row, EndSet returns that query's error, so the query fails. A failure to cache the result is only logged, as the query still gets its rows.
func (*QueryCache) Get ¶
func (c *QueryCache) Get(ctx context.Context, req *CacheRequest, streamUncachedRowFunc, streamCachedRowFunc func(row *sdkproto.Row)) error
func (*QueryCache) IterateSet ¶
func (*QueryCache) SetPluginSchemaMap ¶
func (c *QueryCache) SetPluginSchemaMap(schemaMap map[string]*grpc.PluginSchema)
SetPluginSchemaMap atomically updates the plugin schema map. This is safe to call concurrently with cache reads.
type QueryCacheOptions ¶
func NewQueryCacheOptions ¶
func NewQueryCacheOptions(req *proto.SetCacheOptionsRequest) *QueryCacheOptions