Documentation ¶
Overview ¶
Package cache is an implementation of Azure caches.
Index ¶
- type AzureCacheEntry
- type AzureCacheReadType
- type GetFunc
- type TimedCache
- func (t *TimedCache) Delete(key string) error
- func (t *TimedCache) Get(key string, crt AzureCacheReadType) (interface{}, error)
- func (t *TimedCache) GetWithDeepCopy(key string, crt AzureCacheReadType) (interface{}, error)
- func (t *TimedCache) Set(key string, data interface{})
- func (t *TimedCache) Update(key string, data interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AzureCacheEntry ¶
type AzureCacheEntry struct { Key string Data interface{} // The lock to ensure not updating same entry simultaneously. Lock sync.Mutex // time when entry was fetched and created CreatedOn time.Time }
AzureCacheEntry is the internal structure stores inside TTLStore.
type AzureCacheReadType ¶
type AzureCacheReadType int
AzureCacheReadType defines the read type for cache data
const ( // CacheReadTypeDefault returns data from cache if cache entry not expired // if cache entry expired, then it will refetch the data using getter // save the entry in cache and then return CacheReadTypeDefault AzureCacheReadType = iota // CacheReadTypeUnsafe returns data from cache even if the cache entry is // active/expired. If entry doesn't exist in cache, then data is fetched // using getter, saved in cache and returned CacheReadTypeUnsafe // CacheReadTypeForceRefresh force refreshes the cache even if the cache entry // is not expired CacheReadTypeForceRefresh )
type TimedCache ¶
TimedCache is a cache with TTL.
func NewTimedcache ¶
func NewTimedcache(ttl time.Duration, getter GetFunc) (*TimedCache, error)
NewTimedcache creates a new TimedCache.
func (*TimedCache) Delete ¶
func (t *TimedCache) Delete(key string) error
Delete removes an item from the cache.
func (*TimedCache) Get ¶
func (t *TimedCache) Get(key string, crt AzureCacheReadType) (interface{}, error)
Get returns the requested item by key.
func (*TimedCache) GetWithDeepCopy ¶ added in v1.23.26
func (t *TimedCache) GetWithDeepCopy(key string, crt AzureCacheReadType) (interface{}, error)
Get returns the requested item by key with deep copy.
func (*TimedCache) Set ¶
func (t *TimedCache) Set(key string, data interface{})
Set sets the data cache for the key. It is only used for testing.
func (*TimedCache) Update ¶ added in v1.26.0
func (t *TimedCache) Update(key string, data interface{})
Update updates the data cache for the key.
Click to show internal directories.
Click to hide internal directories.