Documentation ¶
Overview ¶
Package cache is an implementation of Azure caches.
Index ¶
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) Set ¶
func (t *TimedCache) Set(key string, data interface{})
Set sets the data cache for the key. It is only used for testing.
Click to show internal directories.
Click to hide internal directories.