package cache
import "k8s.io/apimachinery/pkg/util/cache"
Index ¶
- type Cache
- func NewCache(maxSize int) Cache
- func (c *Cache) Add(index uint64, obj interface{}) bool
- func (c *Cache) Get(index uint64) (obj interface{}, found bool)
- type Clock
- type LRUExpireCache
- func NewLRUExpireCache(maxSize int) *LRUExpireCache
- func NewLRUExpireCacheWithClock(maxSize int, clock Clock) *LRUExpireCache
- func (c *LRUExpireCache) Add(key interface{}, value interface{}, ttl time.Duration)
- func (c *LRUExpireCache) Get(key interface{}) (interface{}, bool)
- func (c *LRUExpireCache) Keys() []interface{}
- func (c *LRUExpireCache) Remove(key interface{})
Types ¶
type Cache ¶
type Cache []*cacheShard
func NewCache ¶
func (*Cache) Add ¶
Returns true if object already existed, false otherwise.
func (*Cache) Get ¶
type Clock ¶
Clock defines an interface for obtaining the current time
type LRUExpireCache ¶
type LRUExpireCache struct {
// contains filtered or unexported fields
}
LRUExpireCache is a cache that ensures the mostly recently accessed keys are returned with a ttl beyond which keys are forcibly expired.
func NewLRUExpireCache ¶
func NewLRUExpireCache(maxSize int) *LRUExpireCache
NewLRUExpireCache creates an expiring cache with the given size
func NewLRUExpireCacheWithClock ¶
func NewLRUExpireCacheWithClock(maxSize int, clock Clock) *LRUExpireCache
NewLRUExpireCacheWithClock creates an expiring cache with the given size, using the specified clock to obtain the current time.
func (*LRUExpireCache) Add ¶
func (c *LRUExpireCache) Add(key interface{}, value interface{}, ttl time.Duration)
Add adds the value to the cache at key with the specified maximum duration.
func (*LRUExpireCache) Get ¶
func (c *LRUExpireCache) Get(key interface{}) (interface{}, bool)
Get returns the value at the specified key from the cache if it exists and is not expired, or returns false.
func (*LRUExpireCache) Keys ¶
func (c *LRUExpireCache) Keys() []interface{}
Keys returns all the keys in the cache, even if they are expired. Subsequent calls to get may return not found. It returns all keys from oldest to newest.
func (*LRUExpireCache) Remove ¶
func (c *LRUExpireCache) Remove(key interface{})
Remove removes the specified key from the cache if it exists
Source Files ¶
cache.go lruexpirecache.go
- Version
- v0.16.10
- Published
- May 9, 2020
- Platform
- js/wasm
- Imports
- 3 packages
- Last checked
- 8 hours ago –
Tools for package owners.