memory.go (1785B)
1 package cache 2 3 // Memory defines the interface for store of a symbol mapped content cache. 4 type Memory interface { 5 // Add adds a cache value under a cache symbol key. 6 // 7 // Also stores the size limitation of for key for later updates. 8 // 9 // Must fail if: 10 // * key already defined 11 // * value is longer than size limit 12 // * adding value exceeds cumulative cache capacity 13 Add(key string, val string, sizeLimit uint16) error 14 // Update sets a new value for an existing key. 15 // 16 // Uses the size limitation from when the key was added. 17 // 18 // Must fail if: 19 // - key not defined 20 // - value is longer than size limit 21 // - replacing value exceeds cumulative cache capacity 22 Update(key string, val string) error 23 // ReservedSize returns the maximum byte size available for the given symbol. 24 ReservedSize(key string) (uint16, error) 25 // Get the content currently loaded for a single key, loaded at any level. 26 // 27 // Must fail if key has not been loaded. 28 Get(key string) (string, error) 29 // Push adds a new level to the cache. 30 Push() error 31 // Pop frees the cache of the current level and makes the previous level the current level. 32 // 33 // Fails if already on top level. 34 Pop() error 35 // Reset flushes all state contents below the top level. 36 Reset() 37 // Levels returns the current number of levels. 38 Levels() uint32 39 // Keys returns all storage keys for the given level. 40 Keys(level uint32) []string 41 // Last returns the last inserted value 42 // 43 // The stored last inserter value must be reset to an empty string 44 Last() string 45 // Invalidate marks a cache as invalid. 46 // 47 // An invalid cache should not be persisted or propagated 48 Invalidate() 49 // Invalid returns true if cache is invalid. 50 // 51 // An invalid cache should not be persisted or propagated 52 Invalid() bool 53 }