Documentation ¶
Overview ¶
Package cache is a memory store for key-value pairs for all loaded symbols available for output.
Index ¶
- 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) 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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { CacheSize uint32 // Total allowed cumulative size of values (not code) in cache CacheUseSize uint32 // Currently used bytes by all values (not code) in cache Cache []map[string]string // All loaded cache items Sizes map[string]uint16 // Size limits for all loaded symbols. }
Cache stores loaded content, enforcing size limits and keeping track of size usage.
func (*Cache) Add ¶
Add adds a cache value under a cache symbol key.
Also stores the size limitation of for key for later updates.
Fails if: - key already defined - value is longer than size limit - adding value exceeds cumulative cache capacity
func (*Cache) Get ¶
Get the content currently loaded for a single key, loaded at any level.
Fails if key has not been loaded.
func (*Cache) Pop ¶
Pop frees the cache of the current level and makes the previous level the current level.
Fails if already on top level.
func (*Cache) ReservedSize ¶
ReservedSize returns the maximum byte size available for the given symbol.
func (*Cache) Reset ¶
func (ca *Cache) Reset()
Reset flushes all state contents below the top level.
func (*Cache) Update ¶
Update sets a new value for an existing key.
Uses the size limitation from when the key was added.
Fails if: - key not defined - value is longer than size limit - replacing value exceeds cumulative cache capacity
func (*Cache) WithCacheSize ¶
WithCacheSize applies a cumulative cache size limitation for all cached items.
type Memory ¶
type Memory interface { Add(key string, val string, sizeLimit uint16) error Update(key string, val string) error ReservedSize(key string) (uint16, error) Get(key string) (string, error) Push() error Pop() error Reset() }
Memory defines the interface for store of a symbol mapped content store.