Documentation ¶
Overview ¶
Package cache is a memory store for key-value pairs for all loaded symbols available for output.
Index ¶
- Variables
- type Cache
- func (ca *Cache) Add(key string, value string, sizeLimit uint16) error
- func (ca *Cache) Check(key string) bool
- func (ca *Cache) Get(key string) (string, error)
- func (ca *Cache) Invalid() bool
- func (ca *Cache) Invalidate()
- func (ca *Cache) Keys(level uint32) []string
- func (ca *Cache) Last() string
- func (ca *Cache) Levels() uint32
- func (ca *Cache) Pop() error
- func (ca *Cache) Push() error
- func (ca *Cache) ReservedSize(key string) (uint16, error)
- func (ca *Cache) Reset()
- func (ca *Cache) Update(key string, value string) error
- func (ca *Cache) WithCacheSize(cacheSize uint32) *Cache
- type Memory
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { // Total allowed cumulative size of values (not code) in cache CacheSize uint32 // Currently used bytes by all values (not code) in cache CacheUseSize uint32 // All loaded cache items Cache []map[string]string // Size limits for all loaded symbols. Sizes map[string]uint16 // Last inserted value (regardless of scope) LastValue string // contains filtered or unexported fields }
Cache stores loaded content, enforcing size limits and keeping track of size usage.
TODO: hide values from client, while allowing cbor serialization
func (*Cache) Add ¶
Add implements the Memory interface.
func (*Cache) Check ¶
Check returns true if a key already exists in the cache.
func (*Cache) Get ¶
Get implements the Memory interface.
func (*Cache) Invalidate ¶
func (ca *Cache) Invalidate()
Invalidate implements the Memory interface.
func (*Cache) Keys ¶
Keys implements the Memory interface.
func (*Cache) Last ¶
Last implements the Memory interface.
TODO: needs to be invalidated when out of scope
func (*Cache) ReservedSize ¶
ReservedSize implements the Memory interface.
func (*Cache) Update ¶
Update implements the Memory interface.
type Memory ¶
type Memory interface { // Add adds a cache value under a cache symbol key. // // Also stores the size limitation of for key for later updates. // // Must fail if: // * key already defined // * value is longer than size limit // * adding value exceeds cumulative cache capacity Add(key string, val string, sizeLimit uint16) error // Update sets a new value for an existing key. // // Uses the size limitation from when the key was added. // // Must fail if: // - key not defined // - value is longer than size limit // - replacing value exceeds cumulative cache capacity Update(key string, val string) error // ReservedSize returns the maximum byte size available for the given symbol. ReservedSize(key string) (uint16, error) // Get the content currently loaded for a single key, loaded at any level. // // Must fail if key has not been loaded. Get(key string) (string, error) // Push adds a new level to the cache. Push() error // Pop frees the cache of the current level and makes the previous level the current level. // // Fails if already on top level. Pop() error // Reset flushes all state contents below the top level. Reset() // Levels returns the current number of levels. Levels() uint32 // Keys returns all storage keys for the given level. Keys(level uint32) []string // Last returns the last inserted value // // The stored last inserter value must be reset to an empty string Last() string // Invalidate marks a cache as invalid. // // An invalid cache should not be persisted or propagated Invalidate() // Invalid returns true if cache is invalid. // // An invalid cache should not be persisted or propagated Invalid() bool }
Memory defines the interface for store of a symbol mapped content cache.