Documentation
¶
Overview ¶
Package fullrelationcache caches the complete set of relationships for one objecttype:objectid#relation at one revision, and serves relationship queries from that set. A set never serves a query at a different revision.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessCounter ¶
type AccessCounter interface {
// Touch records one access to key and returns its count.
Touch(key string) uint64
// Close releases the counter storage.
Close()
}
AccessCounter counts accesses per set key. The proxy uses the count to decide when an object#relation is hot enough to materialize.
A count is exact for its key while its counter lives. Set keys include the revision, so a count is the number of reads at one revision. A counter expires when no Touch occurs for the window. If the cache evicts a counter or refuses to admit it, the next Touch restarts the count at 1. A restarted count can only delay a materialization. It can never make a served answer wrong.
func NewAccessCounter ¶
func NewAccessCounter(maxCost int64, window time.Duration) (AccessCounter, error)
NewAccessCounter returns an AccessCounter that keeps one counter per key in a pkg/cache cache of maxCost bytes. A counter expires when no Touch occurs for window.
type CachedSet ¶
type CachedSet struct {
// Complete is true if Rels holds every relationship of the object#relation at the revision of the key.
Complete bool
// Rels holds the relationships of a complete set. It is nil for a too-big memo.
Rels []tuple.Relationship
// MemoizedAt is the creation time of a too-big memo. It is zero for a complete set.
MemoizedAt time.Time
}
CachedSet is the value for a SetKey or a too-big memo key. A memo has Complete=false. It sends its object#relation to the datastore at every revision until the memo is older than tooBigMemoReprobeInterval or the cache evicts it.
type Options ¶
type Options struct {
// MaterializeThreshold is the access count at one revision that materializes an object#relation at that revision.
MaterializeThreshold uint64
// MaximumSetSize is the largest set that the proxy stores. A larger set gets a too-big memo.
MaximumSetSize uint64
// NowFunc gives the time for serve-time expiration and too-big memo age. nil means time.Now.
NowFunc func() time.Time
}
Options configures the full relation cache proxy.
type SetKey ¶
type SetKey string
SetKey identifies one object#relation at one revision.
func NewTooBigMemoKey ¶
NewTooBigMemoKey returns the revision-independent key for a too-big memo. A valid type name or object ID cannot start with "!" or contain "::". Thus a memo key never parses as a relationship and never equals a set key.