Documentation ¶
Overview ¶
Package cache is an implementation of Azure caches.
Index ¶
- type AzureCacheEntry
- type AzureCacheReadType
- type GetFunc
- type Resource
- type ResourceProvider
- func (c *ResourceProvider) Delete(_ string) error
- func (c *ResourceProvider) Get(key string, _ AzureCacheReadType) (interface{}, error)
- func (c *ResourceProvider) GetStore() cache.Store
- func (c *ResourceProvider) GetWithDeepCopy(key string, _ AzureCacheReadType) (interface{}, error)
- func (c *ResourceProvider) Lock()
- func (c *ResourceProvider) Set(_ string, _ interface{})
- func (c *ResourceProvider) Unlock()
- func (c *ResourceProvider) Update(_ string, _ interface{})
- type TimedCache
- func (t *TimedCache) Delete(key string) error
- func (t *TimedCache) Get(key string, crt AzureCacheReadType) (interface{}, error)
- func (t *TimedCache) GetStore() cache.Store
- func (t *TimedCache) GetWithDeepCopy(key string, crt AzureCacheReadType) (interface{}, error)
- func (t *TimedCache) Lock()
- func (t *TimedCache) Set(key string, data interface{})
- func (t *TimedCache) Unlock()
- 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 Resource ¶ added in v1.28.0
type Resource interface { Get(key string, crt AzureCacheReadType) (interface{}, error) GetWithDeepCopy(key string, crt AzureCacheReadType) (interface{}, error) Delete(key string) error Set(key string, data interface{}) Update(key string, data interface{}) GetStore() cache.Store Lock() Unlock() }
Resource operations
type ResourceProvider ¶ added in v1.28.0
type ResourceProvider struct {
Getter GetFunc
}
func (*ResourceProvider) Delete ¶ added in v1.28.0
func (c *ResourceProvider) Delete(_ string) error
func (*ResourceProvider) Get ¶ added in v1.28.0
func (c *ResourceProvider) Get(key string, _ AzureCacheReadType) (interface{}, error)
func (*ResourceProvider) GetStore ¶ added in v1.28.0
func (c *ResourceProvider) GetStore() cache.Store
func (*ResourceProvider) GetWithDeepCopy ¶ added in v1.28.0
func (c *ResourceProvider) GetWithDeepCopy(key string, _ AzureCacheReadType) (interface{}, error)
func (*ResourceProvider) Lock ¶ added in v1.28.0
func (c *ResourceProvider) Lock()
func (*ResourceProvider) Set ¶ added in v1.28.0
func (c *ResourceProvider) Set(_ string, _ interface{})
func (*ResourceProvider) Unlock ¶ added in v1.28.0
func (c *ResourceProvider) Unlock()
func (*ResourceProvider) Update ¶ added in v1.28.0
func (c *ResourceProvider) Update(_ string, _ interface{})
type TimedCache ¶
type TimedCache struct { Store cache.Store MutexLock sync.RWMutex TTL time.Duration // contains filtered or unexported fields }
TimedCache is a cache with TTL.
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) GetStore ¶ added in v1.28.0
func (t *TimedCache) GetStore() cache.Store
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) Lock ¶
func (t *TimedCache) Lock()
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) Unlock ¶ added in v1.28.0
func (t *TimedCache) Unlock()
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.