cache

package
v1.2.15-prerelease07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 21 Imported by: 14

Documentation

Overview

Copyright (c) 2017 Uber Technologies, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package cache is a generated GoMock package.

Package cache is a generated GoMock package.

Index

Constants

View Source
const (

	// DomainCacheRefreshInterval domain cache refresh interval
	DomainCacheRefreshInterval = 10 * time.Second
	// DomainCacheRefreshFailureRetryInterval is the wait time
	// if refreshment encounters error
	DomainCacheRefreshFailureRetryInterval = 1 * time.Second
)

Variables

View Source
var (
	// DummyCreateTime is the create time used by all entries in the cache.
	DummyCreateTime = time.Time{}
)
View Source
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")
)
View Source
var SampleRateKey = "sample_retention_rate"

SampleRateKey is key to specify sample rate

View Source
var SampleRetentionKey = "sample_retention_days"

SampleRetentionKey is key to specify sample retention

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 New

func New(opts *Options) Cache

New creates a new cache with the given options

func NewSimple added in v0.12.0

func NewSimple(opts *SimpleOptions) Cache

NewSimple creates a new simple cache with given options. Simple cache will never evict entries and it will never reorder the elements. Simple cache also does not have the concept of pinning that LRU cache has. Internally simple cache uses a RWMutex instead of the exclusive Mutex that LRU cache uses. The RWMutex makes simple cache readable by many threads without introducing lock contention.

type CallbackFn added in v0.3.14

type CallbackFn func(updatedDomains []*DomainCacheEntry)

CallbackFn is function to be called when the domain cache entries are changed it is guaranteed that CallbackFn pair will be both called or non will be called

type DefaultDomainCache added in v1.2.8

type DefaultDomainCache struct {
	// contains filtered or unexported fields
}

func NewDomainCache

func NewDomainCache(
	domainManager persistence.DomainManager,
	metadata cluster.Metadata,
	metricsClient metrics.Client,
	logger log.Logger,
	opts ...DomainCacheOption,
) *DefaultDomainCache

NewDomainCache creates a new instance of cache for holding onto domain information to reduce the load on persistence

func (*DefaultDomainCache) GetAllDomain added in v1.2.8

func (c *DefaultDomainCache) GetAllDomain() map[string]*DomainCacheEntry

func (*DefaultDomainCache) GetCacheSize added in v1.2.8

func (c *DefaultDomainCache) GetCacheSize() (sizeOfCacheByName int64, sizeOfCacheByID int64)

func (*DefaultDomainCache) GetDomain added in v1.2.8

func (c *DefaultDomainCache) GetDomain(
	name string,
) (*DomainCacheEntry, error)

GetDomain retrieves the information from the cache if it exists, otherwise retrieves the information from metadata store and writes it to the cache with an expiry before returning back

func (*DefaultDomainCache) GetDomainByID added in v1.2.8

func (c *DefaultDomainCache) GetDomainByID(
	id string,
) (*DomainCacheEntry, error)

GetDomainByID retrieves the information from the cache if it exists, otherwise retrieves the information from metadata store and writes it to the cache with an expiry before returning back

func (*DefaultDomainCache) GetDomainID added in v1.2.8

func (c *DefaultDomainCache) GetDomainID(
	name string,
) (string, error)

GetDomainID retrieves domainID by using GetDomain

func (*DefaultDomainCache) GetDomainName added in v1.2.8

func (c *DefaultDomainCache) GetDomainName(
	id string,
) (string, error)

GetDomainName returns domain name given the domain id

func (*DefaultDomainCache) RegisterDomainChangeCallback added in v1.2.8

func (c *DefaultDomainCache) RegisterDomainChangeCallback(
	shard int,
	initialNotificationVersion int64,
	prepareCallback PrepareCallbackFn,
	callback CallbackFn,
)

RegisterDomainChangeCallback set a domain change callback WARN: the beforeCallback function will be triggered by domain cache when holding the domain cache lock, make sure the callback function will not call domain cache again in case of dead lock afterCallback will be invoked when NOT holding the domain cache lock.

func (*DefaultDomainCache) Start added in v1.2.8

func (c *DefaultDomainCache) Start()

Start starts the background refresh of domain

func (*DefaultDomainCache) Stop added in v1.2.8

func (c *DefaultDomainCache) Stop()

Stop stops background refresh of domain

func (*DefaultDomainCache) UnregisterDomainChangeCallback added in v1.2.8

func (c *DefaultDomainCache) UnregisterDomainChangeCallback(
	shard int,
)

UnregisterDomainChangeCallback delete a domain failover callback

type DomainCache

type DomainCache interface {
	common.Daemon
	RegisterDomainChangeCallback(shard int, initialNotificationVersion int64, prepareCallback PrepareCallbackFn, callback CallbackFn)
	UnregisterDomainChangeCallback(shard int)
	GetDomain(name string) (*DomainCacheEntry, error)
	GetDomainByID(id string) (*DomainCacheEntry, error)
	GetDomainID(name string) (string, error)
	GetDomainName(id string) (string, error)
	GetAllDomain() map[string]*DomainCacheEntry
	GetCacheSize() (sizeOfCacheByName int64, sizeOfCacheByID int64)
}

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 NewNoOpDomainCache added in v0.25.0

func NewNoOpDomainCache() DomainCache

type DomainCacheEntries added in v0.3.13

type DomainCacheEntries []*DomainCacheEntry

DomainCacheEntries is DomainCacheEntry slice

func (DomainCacheEntries) Len added in v0.3.13

func (t DomainCacheEntries) Len() int

Len return length

func (DomainCacheEntries) Less added in v0.3.13

func (t DomainCacheEntries) Less(i, j int) bool

Less implements sort.Interface

func (DomainCacheEntries) Swap added in v0.3.13

func (t DomainCacheEntries) Swap(i, j int)

Swap implements sort.Interface.

type DomainCacheEntry added in v0.3.12

type DomainCacheEntry struct {
	// contains filtered or unexported fields
}

DomainCacheEntry contains the info and config for a domain

func CreateDomainCacheEntry added in v0.3.14

func CreateDomainCacheEntry(
	domainName string,
) *DomainCacheEntry

CreateDomainCacheEntry create a cache entry with domainName

func GetActiveDomainByID added in v0.25.0

func GetActiveDomainByID(cache DomainCache, currentCluster string, domainID string) (*DomainCacheEntry, error)

func NewDomainCacheEntryForTest added in v0.5.2

func NewDomainCacheEntryForTest(
	info *persistence.DomainInfo,
	config *persistence.DomainConfig,
	isGlobalDomain bool,
	repConfig *persistence.DomainReplicationConfig,
	failoverVersion int64,
	failoverEndtime *int64,
	failoverNotificationVersion int64,
	previousFailoverVersion int64,
	notificationVersion int64,
) *DomainCacheEntry

NewDomainCacheEntryForTest returns an entry with test data

func NewGlobalDomainCacheEntryForTest added in v0.6.0

func NewGlobalDomainCacheEntryForTest(
	info *persistence.DomainInfo,
	config *persistence.DomainConfig,
	repConfig *persistence.DomainReplicationConfig,
	failoverVersion int64,
) *DomainCacheEntry

NewGlobalDomainCacheEntryForTest returns an entry with test data

func NewLocalDomainCacheEntryForTest added in v0.6.0

func NewLocalDomainCacheEntryForTest(
	info *persistence.DomainInfo,
	config *persistence.DomainConfig,
	targetCluster string,
) *DomainCacheEntry

NewLocalDomainCacheEntryForTest returns an entry with test data

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) GetFailoverEndTime added in v0.14.0

func (entry *DomainCacheEntry) GetFailoverEndTime() *int64

GetFailoverEndTime return the failover end time

func (*DomainCacheEntry) GetFailoverNotificationVersion added in v0.3.13

func (entry *DomainCacheEntry) GetFailoverNotificationVersion() int64

GetFailoverNotificationVersion return the global notification version of when failover happened

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) GetNotificationVersion added in v0.3.13

func (entry *DomainCacheEntry) GetNotificationVersion() int64

GetNotificationVersion return the global notification version of when domain changed

func (*DomainCacheEntry) GetPreviousFailoverVersion added in v0.14.0

func (entry *DomainCacheEntry) GetPreviousFailoverVersion() int64

GetPreviousFailoverVersion return the last domain failover version

func (*DomainCacheEntry) GetReplicationConfig added in v0.3.12

func (entry *DomainCacheEntry) GetReplicationConfig() *persistence.DomainReplicationConfig

GetReplicationConfig return the domain replication config

func (*DomainCacheEntry) GetReplicationPolicy added in v0.7.0

func (entry *DomainCacheEntry) GetReplicationPolicy() ReplicationPolicy

GetReplicationPolicy return the derived workflow replication policy

func (*DomainCacheEntry) GetRetentionDays added in v0.4.0

func (entry *DomainCacheEntry) GetRetentionDays(
	workflowID string,
) int32

GetRetentionDays returns retention in days for given workflow

func (*DomainCacheEntry) HasReplicationCluster added in v0.24.0

func (entry *DomainCacheEntry) HasReplicationCluster(clusterName string) bool

HasReplicationCluster returns true if the domain has replication in the cluster

func (*DomainCacheEntry) IsActiveIn added in v0.25.0

func (entry *DomainCacheEntry) IsActiveIn(currentCluster string) (bool, error)

IsActive return whether the domain is active, i.e. non global domain or global domain which active cluster is the current cluster If domain is not active, it also returns an error

func (*DomainCacheEntry) IsDeprecatedOrDeleted added in v1.2.7

func (entry *DomainCacheEntry) IsDeprecatedOrDeleted() bool

IsDeprecatedOrDeleted This function checks the domain status to see if the domain has been deprecated or deleted.

func (*DomainCacheEntry) IsDomainPendingActive added in v0.13.0

func (entry *DomainCacheEntry) IsDomainPendingActive() bool

IsDomainPendingActive returns whether the domain is in pending active state

func (*DomainCacheEntry) IsGlobalDomain added in v0.3.12

func (entry *DomainCacheEntry) IsGlobalDomain() bool

IsGlobalDomain return whether the domain is a global domain

func (*DomainCacheEntry) IsSampledForLongerRetention added in v0.4.0

func (entry *DomainCacheEntry) IsSampledForLongerRetention(
	workflowID string,
) bool

IsSampledForLongerRetention return should given workflow been sampled or not

func (*DomainCacheEntry) IsSampledForLongerRetentionEnabled added in v0.4.0

func (entry *DomainCacheEntry) IsSampledForLongerRetentionEnabled(
	workflowID string,
) bool

IsSampledForLongerRetentionEnabled return whether sample for longer retention is enabled or not

type DomainCacheOption added in v1.2.8

type DomainCacheOption func(*DefaultDomainCache)

func WithTimeSource added in v1.2.8

func WithTimeSource(timeSource clock.TimeSource) DomainCacheOption

type DomainMetricsScopeCache added in v0.14.0

type DomainMetricsScopeCache interface {
	// Get retrieves metrics scope for a domainID and scopeIdx
	Get(domainID string, scopeIdx int) (metrics.Scope, bool)
	// Put adds metrics scope for a domainID and scopeIdx
	Put(domainID string, scopeIdx int, metricsScope metrics.Scope)

	common.Daemon
}

DomainMetricsScopeCache represents a interface for mapping domainID and scopeIdx to metricsScope

func NewDomainMetricsScopeCache added in v0.14.0

func NewDomainMetricsScopeCache() DomainMetricsScopeCache

NewDomainMetricsScopeCache constructs a new domainMetricsScopeCache

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 GetCacheItemSizeFunc added in v0.14.0

type GetCacheItemSizeFunc func(interface{}) uint64

GetCacheItemSizeFunc returns the cache item size in bytes

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 MockCache added in v1.2.8

type MockCache struct {
	// contains filtered or unexported fields
}

MockCache is a mock of Cache interface.

func NewMockCache added in v1.2.8

func NewMockCache(ctrl *gomock.Controller) *MockCache

NewMockCache creates a new mock instance.

func (*MockCache) Delete added in v1.2.8

func (m *MockCache) Delete(key interface{})

Delete mocks base method.

func (*MockCache) EXPECT added in v1.2.8

func (m *MockCache) EXPECT() *MockCacheMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCache) Get added in v1.2.8

func (m *MockCache) Get(key interface{}) interface{}

Get mocks base method.

func (*MockCache) Iterator added in v1.2.8

func (m *MockCache) Iterator() Iterator

Iterator mocks base method.

func (*MockCache) Put added in v1.2.8

func (m *MockCache) Put(key, value interface{}) interface{}

Put mocks base method.

func (*MockCache) PutIfNotExist added in v1.2.8

func (m *MockCache) PutIfNotExist(key, value interface{}) (interface{}, error)

PutIfNotExist mocks base method.

func (*MockCache) Release added in v1.2.8

func (m *MockCache) Release(key interface{})

Release mocks base method.

func (*MockCache) Size added in v1.2.8

func (m *MockCache) Size() int

Size mocks base method.

type MockCacheMockRecorder added in v1.2.8

type MockCacheMockRecorder struct {
	// contains filtered or unexported fields
}

MockCacheMockRecorder is the mock recorder for MockCache.

func (*MockCacheMockRecorder) Delete added in v1.2.8

func (mr *MockCacheMockRecorder) Delete(key interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockCacheMockRecorder) Get added in v1.2.8

func (mr *MockCacheMockRecorder) Get(key interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockCacheMockRecorder) Iterator added in v1.2.8

func (mr *MockCacheMockRecorder) Iterator() *gomock.Call

Iterator indicates an expected call of Iterator.

func (*MockCacheMockRecorder) Put added in v1.2.8

func (mr *MockCacheMockRecorder) Put(key, value interface{}) *gomock.Call

Put indicates an expected call of Put.

func (*MockCacheMockRecorder) PutIfNotExist added in v1.2.8

func (mr *MockCacheMockRecorder) PutIfNotExist(key, value interface{}) *gomock.Call

PutIfNotExist indicates an expected call of PutIfNotExist.

func (*MockCacheMockRecorder) Release added in v1.2.8

func (mr *MockCacheMockRecorder) Release(key interface{}) *gomock.Call

Release indicates an expected call of Release.

func (*MockCacheMockRecorder) Size added in v1.2.8

func (mr *MockCacheMockRecorder) Size() *gomock.Call

Size indicates an expected call of Size.

type MockDomainCache added in v0.11.0

type MockDomainCache struct {
	// contains filtered or unexported fields
}

MockDomainCache is a mock of DomainCache interface.

func NewMockDomainCache added in v0.11.0

func NewMockDomainCache(ctrl *gomock.Controller) *MockDomainCache

NewMockDomainCache creates a new mock instance.

func (*MockDomainCache) EXPECT added in v0.11.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDomainCache) GetAllDomain added in v0.11.0

func (m *MockDomainCache) GetAllDomain() map[string]*DomainCacheEntry

GetAllDomain mocks base method.

func (*MockDomainCache) GetCacheSize added in v0.11.0

func (m *MockDomainCache) GetCacheSize() (int64, int64)

GetCacheSize mocks base method.

func (*MockDomainCache) GetDomain added in v0.11.0

func (m *MockDomainCache) GetDomain(name string) (*DomainCacheEntry, error)

GetDomain mocks base method.

func (*MockDomainCache) GetDomainByID added in v0.11.0

func (m *MockDomainCache) GetDomainByID(id string) (*DomainCacheEntry, error)

GetDomainByID mocks base method.

func (*MockDomainCache) GetDomainID added in v0.11.0

func (m *MockDomainCache) GetDomainID(name string) (string, error)

GetDomainID mocks base method.

func (*MockDomainCache) GetDomainName added in v0.11.0

func (m *MockDomainCache) GetDomainName(id string) (string, error)

GetDomainName mocks base method.

func (*MockDomainCache) RegisterDomainChangeCallback added in v0.11.0

func (m *MockDomainCache) RegisterDomainChangeCallback(shard int, initialNotificationVersion int64, prepareCallback PrepareCallbackFn, callback CallbackFn)

RegisterDomainChangeCallback mocks base method.

func (*MockDomainCache) Start added in v0.11.0

func (m *MockDomainCache) Start()

Start mocks base method.

func (*MockDomainCache) Stop added in v0.11.0

func (m *MockDomainCache) Stop()

Stop mocks base method.

func (*MockDomainCache) UnregisterDomainChangeCallback added in v0.11.0

func (m *MockDomainCache) UnregisterDomainChangeCallback(shard int)

UnregisterDomainChangeCallback mocks base method.

type MockDomainCacheMockRecorder added in v0.11.0

type MockDomainCacheMockRecorder struct {
	// contains filtered or unexported fields
}

MockDomainCacheMockRecorder is the mock recorder for MockDomainCache.

func (*MockDomainCacheMockRecorder) GetAllDomain added in v0.11.0

func (mr *MockDomainCacheMockRecorder) GetAllDomain() *gomock.Call

GetAllDomain indicates an expected call of GetAllDomain.

func (*MockDomainCacheMockRecorder) GetCacheSize added in v0.11.0

func (mr *MockDomainCacheMockRecorder) GetCacheSize() *gomock.Call

GetCacheSize indicates an expected call of GetCacheSize.

func (*MockDomainCacheMockRecorder) GetDomain added in v0.11.0

func (mr *MockDomainCacheMockRecorder) GetDomain(name interface{}) *gomock.Call

GetDomain indicates an expected call of GetDomain.

func (*MockDomainCacheMockRecorder) GetDomainByID added in v0.11.0

func (mr *MockDomainCacheMockRecorder) GetDomainByID(id interface{}) *gomock.Call

GetDomainByID indicates an expected call of GetDomainByID.

func (*MockDomainCacheMockRecorder) GetDomainID added in v0.11.0

func (mr *MockDomainCacheMockRecorder) GetDomainID(name interface{}) *gomock.Call

GetDomainID indicates an expected call of GetDomainID.

func (*MockDomainCacheMockRecorder) GetDomainName added in v0.11.0

func (mr *MockDomainCacheMockRecorder) GetDomainName(id interface{}) *gomock.Call

GetDomainName indicates an expected call of GetDomainName.

func (*MockDomainCacheMockRecorder) RegisterDomainChangeCallback added in v0.11.0

func (mr *MockDomainCacheMockRecorder) RegisterDomainChangeCallback(shard, initialNotificationVersion, prepareCallback, callback interface{}) *gomock.Call

RegisterDomainChangeCallback indicates an expected call of RegisterDomainChangeCallback.

func (*MockDomainCacheMockRecorder) Start added in v0.11.0

Start indicates an expected call of Start.

func (*MockDomainCacheMockRecorder) Stop added in v0.11.0

Stop indicates an expected call of Stop.

func (*MockDomainCacheMockRecorder) UnregisterDomainChangeCallback added in v0.11.0

func (mr *MockDomainCacheMockRecorder) UnregisterDomainChangeCallback(shard interface{}) *gomock.Call

UnregisterDomainChangeCallback indicates an expected call of UnregisterDomainChangeCallback.

type MockDomainMetricsScopeCache added in v1.2.8

type MockDomainMetricsScopeCache struct {
	// contains filtered or unexported fields
}

MockDomainMetricsScopeCache is a mock of DomainMetricsScopeCache interface.

func NewMockDomainMetricsScopeCache added in v1.2.8

func NewMockDomainMetricsScopeCache(ctrl *gomock.Controller) *MockDomainMetricsScopeCache

NewMockDomainMetricsScopeCache creates a new mock instance.

func (*MockDomainMetricsScopeCache) EXPECT added in v1.2.8

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDomainMetricsScopeCache) Get added in v1.2.8

func (m *MockDomainMetricsScopeCache) Get(domainID string, scopeIdx int) (metrics.Scope, bool)

Get mocks base method.

func (*MockDomainMetricsScopeCache) Put added in v1.2.8

func (m *MockDomainMetricsScopeCache) Put(domainID string, scopeIdx int, metricsScope metrics.Scope)

Put mocks base method.

func (*MockDomainMetricsScopeCache) Start added in v1.2.8

func (m *MockDomainMetricsScopeCache) Start()

Start mocks base method.

func (*MockDomainMetricsScopeCache) Stop added in v1.2.8

func (m *MockDomainMetricsScopeCache) Stop()

Stop mocks base method.

type MockDomainMetricsScopeCacheMockRecorder added in v1.2.8

type MockDomainMetricsScopeCacheMockRecorder struct {
	// contains filtered or unexported fields
}

MockDomainMetricsScopeCacheMockRecorder is the mock recorder for MockDomainMetricsScopeCache.

func (*MockDomainMetricsScopeCacheMockRecorder) Get added in v1.2.8

func (mr *MockDomainMetricsScopeCacheMockRecorder) Get(domainID, scopeIdx interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockDomainMetricsScopeCacheMockRecorder) Put added in v1.2.8

func (mr *MockDomainMetricsScopeCacheMockRecorder) Put(domainID, scopeIdx, metricsScope interface{}) *gomock.Call

Put indicates an expected call of Put.

func (*MockDomainMetricsScopeCacheMockRecorder) Start added in v1.2.8

Start indicates an expected call of Start.

func (*MockDomainMetricsScopeCacheMockRecorder) Stop added in v1.2.8

Stop indicates an expected call of Stop.

type MockEntry added in v1.2.8

type MockEntry struct {
	// contains filtered or unexported fields
}

MockEntry is a mock of Entry interface.

func NewMockEntry added in v1.2.8

func NewMockEntry(ctrl *gomock.Controller) *MockEntry

NewMockEntry creates a new mock instance.

func (*MockEntry) CreateTime added in v1.2.8

func (m *MockEntry) CreateTime() time.Time

CreateTime mocks base method.

func (*MockEntry) EXPECT added in v1.2.8

func (m *MockEntry) EXPECT() *MockEntryMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEntry) Key added in v1.2.8

func (m *MockEntry) Key() interface{}

Key mocks base method.

func (*MockEntry) Value added in v1.2.8

func (m *MockEntry) Value() interface{}

Value mocks base method.

type MockEntryMockRecorder added in v1.2.8

type MockEntryMockRecorder struct {
	// contains filtered or unexported fields
}

MockEntryMockRecorder is the mock recorder for MockEntry.

func (*MockEntryMockRecorder) CreateTime added in v1.2.8

func (mr *MockEntryMockRecorder) CreateTime() *gomock.Call

CreateTime indicates an expected call of CreateTime.

func (*MockEntryMockRecorder) Key added in v1.2.8

func (mr *MockEntryMockRecorder) Key() *gomock.Call

Key indicates an expected call of Key.

func (*MockEntryMockRecorder) Value added in v1.2.8

func (mr *MockEntryMockRecorder) Value() *gomock.Call

Value indicates an expected call of Value.

type MockIterator added in v1.2.8

type MockIterator struct {
	// contains filtered or unexported fields
}

MockIterator is a mock of Iterator interface.

func NewMockIterator added in v1.2.8

func NewMockIterator(ctrl *gomock.Controller) *MockIterator

NewMockIterator creates a new mock instance.

func (*MockIterator) Close added in v1.2.8

func (m *MockIterator) Close()

Close mocks base method.

func (*MockIterator) EXPECT added in v1.2.8

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIterator) HasNext added in v1.2.8

func (m *MockIterator) HasNext() bool

HasNext mocks base method.

func (*MockIterator) Next added in v1.2.8

func (m *MockIterator) Next() Entry

Next mocks base method.

type MockIteratorMockRecorder added in v1.2.8

type MockIteratorMockRecorder struct {
	// contains filtered or unexported fields
}

MockIteratorMockRecorder is the mock recorder for MockIterator.

func (*MockIteratorMockRecorder) Close added in v1.2.8

func (mr *MockIteratorMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close.

func (*MockIteratorMockRecorder) HasNext added in v1.2.8

func (mr *MockIteratorMockRecorder) HasNext() *gomock.Call

HasNext indicates an expected call of HasNext.

func (*MockIteratorMockRecorder) Next added in v1.2.8

func (mr *MockIteratorMockRecorder) Next() *gomock.Call

Next indicates an expected call of Next.

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

	// MaxCount controls the max capacity of the cache
	// It is required option if MaxSize is not provided
	MaxCount int

	// GetCacheItemSizeFunc is a function called upon adding the item to update the cache size.
	// It returns 0 by default, assuming the cache is just count based
	// It is required option if MaxCount is not provided
	GetCacheItemSizeFunc GetCacheItemSizeFunc

	// MaxSize is an optional and must be set along with GetCacheItemSizeFunc
	// to control the max size in bytes of the cache
	// It is required option if MaxCount is not provided
	MaxSize uint64

	// ActivelyEvict will evict items that has expired TTL at every operation in the cache
	// This can be expensive if a lot of items expire at the same time
	// Should be used when it's important for memory that the expired items are evicted as soon as possible
	// If not set expired items will be evicted when one of these happens
	// - when the cache is full
	// - when the item is accessed
	ActivelyEvict bool

	// TimeSource is used to get the current time
	// It is optional and defaults to clock.NewRealTimeSource()
	TimeSource clock.TimeSource
}

Options control the behavior of the cache

type PrepareCallbackFn added in v0.5.0

type PrepareCallbackFn func()

PrepareCallbackFn is function to be called before CallbackFn is called, it is guaranteed that PrepareCallbackFn and CallbackFn pair will be both called or non will be called

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)

type ReplicationPolicy added in v0.7.0

type ReplicationPolicy int

ReplicationPolicy is the domain's replication policy, derived from domain's replication config

const (
	// ReplicationPolicyOneCluster indicate that workflows does not need to be replicated
	// applicable to local domain & global domain with one cluster
	ReplicationPolicyOneCluster ReplicationPolicy = 0
	// ReplicationPolicyMultiCluster indicate that workflows need to be replicated
	ReplicationPolicyMultiCluster ReplicationPolicy = 1
)

type SimpleOptions added in v0.12.0

type SimpleOptions struct {
	// InitialCapacity controls the initial capacity of the cache
	InitialCapacity int

	// RemovedFunc is an optional function called when an element
	// is scheduled for deletion
	RemovedFunc RemovedFunc
}

SimpleOptions provides options that can be used to configure SimpleCache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL