memorycache

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultService

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

func NewDefaultService

func NewDefaultService() *DefaultService

func (*DefaultService) Get

func (s *DefaultService) Get(ctx context.Context, stateReference reference.Global) (descriptor.Object, error)

func (*DefaultService) Set

func (s *DefaultService) Set(ctx context.Context, stateReference reference.Global, objectDescriptor descriptor.Object) error

type Key

type Key = reference.Global

type LRUMemoryCache

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

func NewMemoryCache

func NewMemoryCache(cs cachekit.Strategy) *LRUMemoryCache

func (*LRUMemoryCache) Allocated

func (p *LRUMemoryCache) Allocated() int

Allocated returns a total number of cache entries allocated, but some of them may be unused. NB! Cache can only grow.

func (*LRUMemoryCache) Contains

func (p *LRUMemoryCache) Contains(key Key) bool

Contains returns (true) when the key is present. Access to the key is not updated.

func (*LRUMemoryCache) Delete

func (p *LRUMemoryCache) Delete(key Key) bool

Delete removes key and zero out relevant value. Returns (false) when key wasn't present. Access to the key is not updated. Cache entry will become unavailable, but will only be freed after relevant expiry / eviction.

func (*LRUMemoryCache) Get

func (p *LRUMemoryCache) Get(key Key) (Value, bool)

Get returns value and presence flag for the given key. Access to the key is updated when key exists.

func (*LRUMemoryCache) Occupied

func (p *LRUMemoryCache) Occupied() int

Occupied returns a number of added / available cache entries.

func (*LRUMemoryCache) Peek

func (p *LRUMemoryCache) Peek(key Key) (Value, bool)

Peek returns value and presence flag for the given key. Access to the key is not updated.

func (*LRUMemoryCache) Put

func (p *LRUMemoryCache) Put(key Key, value Value) bool

Put adds value with the given key. If key was already added, then cached value remains unchanged and the function returns (false). Access to the key is always updated.

func (*LRUMemoryCache) Replace

func (p *LRUMemoryCache) Replace(key Key, value Value) bool

Replace adds or replaces value with the given key. If key was already added, then cached value is updated and the function returns (false). Access to the key is always updated.

type Service

type Service interface {
	Get(ctx context.Context, stateReference reference.Global) (descriptor.Object, error)
	Set(ctx context.Context, stateReference reference.Global, objectDescriptor descriptor.Object) error
}

type ServiceMock

type ServiceMock struct {
	GetMock mServiceMockGet

	SetMock mServiceMockSet
	// contains filtered or unexported fields
}

ServiceMock implements Service

func NewServiceMock

func NewServiceMock(t minimock.Tester) *ServiceMock

NewServiceMock returns a mock for Service

func (*ServiceMock) Get

func (mmGet *ServiceMock) Get(ctx context.Context, stateReference reference.Global) (o1 descriptor.Object, err error)

Get implements Service

func (*ServiceMock) GetAfterCounter

func (mmGet *ServiceMock) GetAfterCounter() uint64

GetAfterCounter returns a count of finished ServiceMock.Get invocations

func (*ServiceMock) GetBeforeCounter

func (mmGet *ServiceMock) GetBeforeCounter() uint64

GetBeforeCounter returns a count of ServiceMock.Get invocations

func (*ServiceMock) MinimockFinish

func (m *ServiceMock) MinimockFinish()

MinimockFinish checks that all mocked methods have been called the expected number of times

func (*ServiceMock) MinimockGetDone

func (m *ServiceMock) MinimockGetDone() bool

MinimockGetDone returns true if the count of the Get invocations corresponds the number of defined expectations

func (*ServiceMock) MinimockGetInspect

func (m *ServiceMock) MinimockGetInspect()

MinimockGetInspect logs each unmet expectation

func (*ServiceMock) MinimockSetDone

func (m *ServiceMock) MinimockSetDone() bool

MinimockSetDone returns true if the count of the Set invocations corresponds the number of defined expectations

func (*ServiceMock) MinimockSetInspect

func (m *ServiceMock) MinimockSetInspect()

MinimockSetInspect logs each unmet expectation

func (*ServiceMock) MinimockWait

func (m *ServiceMock) MinimockWait(timeout mm_time.Duration)

MinimockWait waits for all mocked methods to be called the expected number of times

func (*ServiceMock) Set

func (mmSet *ServiceMock) Set(ctx context.Context, stateReference reference.Global, objectDescriptor descriptor.Object) (err error)

Set implements Service

func (*ServiceMock) SetAfterCounter

func (mmSet *ServiceMock) SetAfterCounter() uint64

SetAfterCounter returns a count of finished ServiceMock.Set invocations

func (*ServiceMock) SetBeforeCounter

func (mmSet *ServiceMock) SetBeforeCounter() uint64

SetBeforeCounter returns a count of ServiceMock.Set invocations

type ServiceMockGetExpectation

type ServiceMockGetExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

ServiceMockGetExpectation specifies expectation struct of the Service.Get

func (*ServiceMockGetExpectation) Then

Then sets up Service.Get return parameters for the expectation previously defined by the When method

type ServiceMockGetParams

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

ServiceMockGetParams contains parameters of the Service.Get

type ServiceMockGetResults

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

ServiceMockGetResults contains results of the Service.Get

type ServiceMockSetExpectation

type ServiceMockSetExpectation struct {
	Counter uint64
	// contains filtered or unexported fields
}

ServiceMockSetExpectation specifies expectation struct of the Service.Set

func (*ServiceMockSetExpectation) Then

Then sets up Service.Set return parameters for the expectation previously defined by the When method

type ServiceMockSetParams

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

ServiceMockSetParams contains parameters of the Service.Set

type ServiceMockSetResults

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

ServiceMockSetResults contains results of the Service.Set

type Value

type Value = descriptor.Object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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