Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

37 řádky
1.1 KiB

  1. package simplelru
  2. // LRUCache is the interface for simple LRU cache.
  3. type LRUCache interface {
  4. // Adds a value to the cache, returns true if an eviction occurred and
  5. // updates the "recently used"-ness of the key.
  6. Add(key, value interface{}) bool
  7. // Returns key's value from the cache and
  8. // updates the "recently used"-ness of the key. #value, isFound
  9. Get(key interface{}) (value interface{}, ok bool)
  10. // Check if a key exsists in cache without updating the recent-ness.
  11. Contains(key interface{}) (ok bool)
  12. // Returns key's value without updating the "recently used"-ness of the key.
  13. Peek(key interface{}) (value interface{}, ok bool)
  14. // Removes a key from the cache.
  15. Remove(key interface{}) bool
  16. // Removes the oldest entry from cache.
  17. RemoveOldest() (interface{}, interface{}, bool)
  18. // Returns the oldest entry from the cache. #key, value, isFound
  19. GetOldest() (interface{}, interface{}, bool)
  20. // Returns a slice of the keys in the cache, from oldest to newest.
  21. Keys() []interface{}
  22. // Returns the number of items in the cache.
  23. Len() int
  24. // Clear all cache entries
  25. Purge()
  26. }