Documentation
¶
Index ¶
- Constants
- func DelExpiry(obj *object.Obj, store *Store)
- func DeleteExpiredKeys(store *Store)
- func EvaluateAndSetExpiry(subCommands []string, newExpiryAbsMillis int64, key string, store *Store) (shouldSetExpiry bool, err error)
- func GetExpiry(obj *object.Obj, store *Store) (int64, bool)
- func GetIdleTime(lastAccessedAt int64) int64
- func NewExpireMap() common.ITable[*object.Obj, int64]
- func NewExpireRegMap() common.ITable[*object.Obj, int64]
- func NewStoreMap() common.ITable[string, *object.Obj]
- func NewStoreRegMap() common.ITable[string, *object.Obj]
- type AOF
- type AccessType
- type BaseEvictionStrategy
- type CmdWatchEvent
- type DelOption
- type DelOptions
- type EvictionResult
- type EvictionStats
- type EvictionStrategy
- type PrimitiveEvictionStrategy
- type PutOption
- type PutOptions
- type QueryWatchEvent
- type Store
- func (store *Store) Del(k string, opts ...DelOption) bool
- func (store *Store) DelByPtr(ptr string, opts ...DelOption) bool
- func (store *Store) Get(k string) *object.Obj
- func (store *Store) GetAll(keys []string) []*object.Obj
- func (store *Store) GetDBSize() uint64
- func (store *Store) GetDel(k string, opts ...DelOption) *object.Obj
- func (store *Store) GetKeyCount() int
- func (store *Store) GetNoTouch(k string) *object.Obj
- func (store *Store) GetStore() common.ITable[string, *object.Obj]
- func (store *Store) IncrementKeyCount()
- func (store *Store) Keys(p string) ([]string, error)
- func (store *Store) NewObj(value interface{}, expDurationMs int64, oType object.ObjectType) *object.Obj
- func (store *Store) Put(k string, obj *object.Obj, opts ...PutOption)
- func (store *Store) PutAll(data map[string]*object.Obj)
- func (store *Store) Rename(sourceKey, destKey string) bool
- func (store *Store) ResetStore()
- func (store *Store) SetExpiry(obj *object.Obj, expDurationMs int64)
- func (store *Store) SetUnixTimeExpiry(obj *object.Obj, exUnixTimeMillis int64)
Constants ¶
const ( Set string = "SET" Del string = "DEL" Get string = "GET" Rename string = "RENAME" ZAdd string = "ZADD" ZRange string = "ZRANGE" Replace string = "REPLACE" Smembers string = "SMEMBERS" JSONGet string = "JSON.GET" PFADD string = "PFADD" PFCOUNT string = "PFCOUNT" PFMERGE string = "PFMERGE" KEYSPERSHARD string = "KEYSPERSHARD" Evict string = "EVICT" SingleShardSize string = "SINGLEDBSIZE" SingleShardTouch string = "SINGLETOUCH" SingleShardKeys string = "SINGLEKEYS" FlushDB string = "FLUSHDB" )
const ( NX string = "NX" XX string = "XX" GT string = "GT" LT string = "LT" )
const (
FileMode int = 0644
)
Variables ¶
This section is empty.
Functions ¶
func DeleteExpiredKeys ¶
func DeleteExpiredKeys(store *Store)
DeleteExpiredKeys deletes all the expired keys - the active way
func EvaluateAndSetExpiry ¶
func EvaluateAndSetExpiry(subCommands []string, newExpiryAbsMillis int64, key string, store *Store) (shouldSetExpiry bool, err error)
NX: Set the expiration only if the key does not already have an expiration time. XX: Set the expiration only if the key already has an expiration time. GT: Set the expiration only if the new expiration time is greater than the current one. LT: Set the expiration only if the new expiration time is less than the current one. Returns Boolean True and error nil if expiry was set on the key successfully. Returns Boolean False and error nil if conditions didn't met. Returns Boolean False and error not-nil if invalid combination of subCommands or if subCommand is invalid
func GetIdleTime ¶
Types ¶
type AccessType ¶
type AccessType int
AccessType represents different types of access to a key
const ( AccessGet AccessType = iota AccessSet AccessDel )
type BaseEvictionStrategy ¶
type BaseEvictionStrategy struct {
// contains filtered or unexported fields
}
BaseEvictionStrategy provides common functionality for all eviction strategies
func (*BaseEvictionStrategy) AfterEviction ¶
func (b *BaseEvictionStrategy) AfterEviction(result EvictionResult)
func (*BaseEvictionStrategy) GetStats ¶
func (b *BaseEvictionStrategy) GetStats() EvictionStats
type CmdWatchEvent ¶
type DelOptions ¶
type DelOptions struct {
DelCmd string
}
type EvictionResult ¶
type EvictionResult struct { Victims map[string]*object.Obj // Keys and objects that were selected for eviction Count int64 // Number of items selected for eviction }
EvictionResult represents the outcome of an eviction operation
type EvictionStats ¶
type EvictionStats struct {
// contains filtered or unexported fields
}
EvictionStats tracks common statistics for all eviction strategies
type EvictionStrategy ¶
type EvictionStrategy interface { // ShouldEvict checks if eviction should be triggered based on the current store state // Returns the number of items that should be evicted, or 0 if no eviction is needed ShouldEvict(store *Store) int // EvictVictims evicts items from the store based on the eviction strategy EvictVictims(store *Store, toEvict int) // OnAccess is called when an item is accessed (get/set) // This allows strategies to update access patterns/statistics OnAccess(key string, obj *object.Obj, accessType AccessType) }
EvictionStrategy defines the interface for different eviction strategies
func NewDefaultEviction ¶
func NewDefaultEviction() EvictionStrategy
type PrimitiveEvictionStrategy ¶
type PrimitiveEvictionStrategy struct { BaseEvictionStrategy // contains filtered or unexported fields }
PrimitiveEvictionStrategy implements batch eviction of least recently used keys
func NewPrimitiveEvictionStrategy ¶
func NewPrimitiveEvictionStrategy(maxKeys int) *PrimitiveEvictionStrategy
func (*PrimitiveEvictionStrategy) EvictVictims ¶
func (e *PrimitiveEvictionStrategy) EvictVictims(store *Store, toEvict int)
EvictVictims deletes keys with the lowest LastAccessedAt values from the store.
func (*PrimitiveEvictionStrategy) OnAccess ¶
func (e *PrimitiveEvictionStrategy) OnAccess(key string, obj *object.Obj, accessType AccessType)
func (*PrimitiveEvictionStrategy) ShouldEvict ¶
func (e *PrimitiveEvictionStrategy) ShouldEvict(store *Store) int
type PutOptions ¶
type QueryWatchEvent ¶
QueryWatchEvent represents a change in a watched key.
type Store ¶
type Store struct { ShardID int // contains filtered or unexported fields }
func NewStore ¶
func NewStore(cmdWatchChan chan CmdWatchEvent, evictionStrategy EvictionStrategy, shardID int) *Store
func (*Store) GetKeyCount ¶
func (*Store) IncrementKeyCount ¶
func (store *Store) IncrementKeyCount()
func (*Store) ResetStore ¶
func (store *Store) ResetStore()