Documentation
¶
Overview ¶
Package index defines the Trickster Cache Index
Index ¶
- Constants
- type Index
- func (idx *Index) Close()
- func (z *Index) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Index) EncodeMsg(en *msgp.Writer) (err error)
- func (idx *Index) GetExpiration(cacheKey string) time.Time
- func (z *Index) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Index) Msgsize() (s int)
- func (idx *Index) RemoveObject(key string)
- func (idx *Index) RemoveObjects(keys []string, noLock bool)
- func (idx *Index) ToBytes() []byte
- func (z *Index) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (idx *Index) UpdateObject(obj *Object)
- func (idx *Index) UpdateObjectAccessTime(key string)
- func (idx *Index) UpdateObjectTTL(key string, ttl time.Duration)
- func (idx *Index) UpdateOptions(o *options.Options)
- type Object
- func (z *Object) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Object) EncodeMsg(en *msgp.Writer) (err error)
- func (z *Object) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Object) Msgsize() (s int)
- func (o *Object) ToBytes() []byte
- func (z *Object) UnmarshalMsg(bts []byte) (o []byte, err error)
Constants ¶
const IndexKey = "cache.index"
IndexKey is the key under which the index will write itself to its associated cache
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// CacheSize represents the size of the cache in bytes
CacheSize int64 `msg:"cache_size"`
// ObjectCount represents the count of objects in the Cache
ObjectCount int64 `msg:"object_count"`
// Objects is a map of Objects in the Cache
Objects map[string]*Object `msg:"objects"`
// contains filtered or unexported fields
}
Index maintains metadata about a Cache when Retention enforcement is managed internally, like memory or bbolt. It is not used for independently managed caches like Redis.
func NewIndex ¶
func NewIndex(cacheName, cacheType string, indexData []byte, o *options.Options, bulkRemoveFunc func([]string), flushFunc func(cacheKey string, data []byte), log *tl.Logger) *Index
NewIndex returns a new Index based on the provided inputs
func (*Index) Close ¶
func (idx *Index) Close()
Close is called to signal the index to shut down any subroutines
func (*Index) GetExpiration ¶
GetExpiration returns the cache index's expiration for the object of the given key
func (*Index) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Index) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Index) RemoveObject ¶
RemoveObject removes an Object's Metadata from the Index
func (*Index) RemoveObjects ¶
RemoveObjects removes a list of Objects' Metadata from the Index
func (*Index) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Index) UpdateObject ¶
UpdateObject writes or updates the Index Metadata for the provided Object
func (*Index) UpdateObjectAccessTime ¶
UpdateObjectAccessTime updates the LastAccess for the object with the provided key
func (*Index) UpdateObjectTTL ¶
UpdateObjectTTL updates the Expiration for the object with the provided key
func (*Index) UpdateOptions ¶
UpdateOptions updates the existing Index with a new Options reference
type Object ¶
type Object struct {
// Key represents the name of the Object and is the
// accessor in a hashed collection of Cache Objects
Key string `msg:"key"`
// Expiration represents the time that the Object expires from Cache
Expiration time.Time `msg:"expiration"`
// LastWrite is the time the object was last Written
LastWrite time.Time `msg:"lastwrite"`
// LastAccess is the time the object was last Accessed
LastAccess time.Time `msg:"lastaccess"`
// Size the size of the Object in bytes
Size int64 `msg:"size"`
// Value is the value of the Object stored in the Cache
// It is used by Caches but not by the Index
Value []byte `msg:"value,omitempty"`
// DirectValue is an interface value for storing objects by reference to a memory cache
// Since we'd never recover a memory cache index from memory on startup, no need to msgpk
ReferenceValue cache.ReferenceObject `msg:"-"`
}
Object contains metadata about an item in the Cache
func ObjectFromBytes ¶
ObjectFromBytes returns a deserialized Cache Object from a seralized byte slice
func (*Object) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Object) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message