Documentation ¶
Index ¶
- Variables
- type Cache
- type DomainCache
- type DomainCacheEntry
- func (entry *DomainCacheEntry) GetConfig() *persistence.DomainConfig
- func (entry *DomainCacheEntry) GetConfigVersion() int64
- func (entry *DomainCacheEntry) GetDomainNotActiveErr() error
- func (entry *DomainCacheEntry) GetFailoverVersion() int64
- func (entry *DomainCacheEntry) GetInfo() *persistence.DomainInfo
- func (entry *DomainCacheEntry) GetReplicationConfig() *persistence.DomainReplicationConfig
- func (entry *DomainCacheEntry) IsDomainActive() bool
- func (entry *DomainCacheEntry) IsGlobalDomain() bool
- func (entry *DomainCacheEntry) ShouldReplicateEvent() bool
- type Entry
- type Iterator
- type Options
- type RemovedFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCacheFull is returned if Put fails due to cache being filled with pinned elements ErrCacheFull = errors.New("Cache capacity is fully occupied with pinned elements") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get retrieves an element based on a key, returning nil if the element // does not exist Get(key interface{}) interface{} // Put adds an element to the cache, returning the previous element Put(key interface{}, value interface{}) interface{} // PutIfNotExist puts a value associated with a given key if it does not exist PutIfNotExist(key interface{}, value interface{}) (interface{}, error) // Delete deletes an element in the cache Delete(key interface{}) // Release decrements the ref count of a pinned element. If the ref count // drops to 0, the element can be evicted from the cache. Release(key interface{}) // Iterator returns the iterator of the cache Iterator() Iterator // Size returns the number of entries currently stored in the Cache Size() int }
A Cache is a generalized interface to a cache. See cache.LRU for a specific implementation (bounded cache with LRU eviction)
func NewLRU ¶
NewLRU creates a new LRU cache of the given size, setting initial capacity to the max size
func NewLRUWithInitialCapacity ¶
NewLRUWithInitialCapacity creates a new LRU cache with an initial capacity and a max size
type DomainCache ¶
type DomainCache interface { RegisterDomainChangeCallback(shard int, fn callbackFn) UnregisterDomainChangeCallback(shard int) GetDomain(name string) (*DomainCacheEntry, error) GetDomainByID(id string) (*DomainCacheEntry, error) GetDomainID(name string) (string, error) }
DomainCache is used the cache domain information and configuration to avoid making too many calls to cassandra. This cache is mainly used by frontend for resolving domain names to domain uuids which are used throughout the system. Each domain entry is kept in the cache for one hour but also has an expiry of 10 seconds. This results in updating the domain entry every 10 seconds but in the case of a cassandra failure we can still keep on serving requests using the stale entry from cache upto an hour
func NewDomainCache ¶
func NewDomainCache(metadataMgr persistence.MetadataManager, clusterMetadata cluster.Metadata, logger bark.Logger) DomainCache
NewDomainCache creates a new instance of cache for holding onto domain information to reduce the load on persistence
type DomainCacheEntry ¶ added in v0.3.12
DomainCacheEntry contains the info and config for a domain
func (*DomainCacheEntry) GetConfig ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetConfig() *persistence.DomainConfig
GetConfig return the domain config
func (*DomainCacheEntry) GetConfigVersion ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetConfigVersion() int64
GetConfigVersion return the domain config version
func (*DomainCacheEntry) GetDomainNotActiveErr ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetDomainNotActiveErr() error
GetDomainNotActiveErr return err if domain is not active, nil otherwise
func (*DomainCacheEntry) GetFailoverVersion ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetFailoverVersion() int64
GetFailoverVersion return the domain failover version
func (*DomainCacheEntry) GetInfo ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetInfo() *persistence.DomainInfo
GetInfo return the domain info
func (*DomainCacheEntry) GetReplicationConfig ¶ added in v0.3.12
func (entry *DomainCacheEntry) GetReplicationConfig() *persistence.DomainReplicationConfig
GetReplicationConfig return the domain replication config
func (*DomainCacheEntry) IsDomainActive ¶ added in v0.3.12
func (entry *DomainCacheEntry) IsDomainActive() bool
IsDomainActive return whether the domain is active, i.e. non global domain or global domain which active cluster is the current cluster
func (*DomainCacheEntry) IsGlobalDomain ¶ added in v0.3.12
func (entry *DomainCacheEntry) IsGlobalDomain() bool
IsGlobalDomain return whether the domain is a global domain
func (*DomainCacheEntry) ShouldReplicateEvent ¶ added in v0.3.12
func (entry *DomainCacheEntry) ShouldReplicateEvent() bool
ShouldReplicateEvent return whether the workflows within this domain should be replicated
type Entry ¶ added in v0.3.5
type Entry interface { // Key represents the key Key() interface{} // Value represents the value Value() interface{} // CreateTime represents the time when the entry is created CreateTime() time.Time }
Entry represents a key-value entry within the map
type Iterator ¶ added in v0.3.5
type Iterator interface { // Close closes the iterator // and releases any allocated resources Close() // HasNext return true if there is more items to be returned HasNext() bool // Next return the next item Next() Entry }
Iterator represents the interface for cache iterators
type Options ¶
type Options struct { // TTL controls the time-to-live for a given cache entry. Cache entries that // are older than the TTL will not be returned TTL time.Duration // InitialCapacity controls the initial capacity of the cache InitialCapacity int // Pin prevents in-use objects from getting evicted Pin bool // RemovedFunc is an optional function called when an element // is scheduled for deletion RemovedFunc RemovedFunc }
Options control the behavior of the cache
type RemovedFunc ¶
type RemovedFunc func(interface{})
RemovedFunc is a type for notifying applications when an item is scheduled for removal from the Cache. If f is a function with the appropriate signature and i is the interface{} scheduled for deletion, Cache calls go f(i)