memory

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache describes an in-memory cache with automatic expiration

func (Cache) GetVerifyResult

func (memoryCache Cache) GetVerifyResult(_ context.Context, subjectRefString string) (et.VerifyResult, bool)

func (Cache) SetVerifyResult

func (memoryCache Cache) SetVerifyResult(_ context.Context, subjectRefString string, verifyResult et.VerifyResult, ttl time.Duration)

type SyncMap

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

SyncMap is a map with synchronized access support

func MakeSyncMap

func MakeSyncMap(maxEntries int) SyncMap

MakeSyncMap create a new SyncMap if maxEntries is 0, the capacity if override as 1

func (*SyncMap) DeleteEntry

func (sm *SyncMap) DeleteEntry(key string)

DeleteEntry delete an entry TODO evaluate need for delete

func (*SyncMap) GetEntry

func (sm *SyncMap) GetEntry(key string) (entry interface{}, ok bool)

GetEntry gets an entry

func (*SyncMap) GetLength

func (sm *SyncMap) GetLength() int

GetLength get the number of items in the map

func (*SyncMap) SetEntry

func (sm *SyncMap) SetEntry(key string, entry interface{})

SetEntry adds a new entry or update existing entry

func (*SyncMap) SetEvictionPercentage

func (sm *SyncMap) SetEvictionPercentage(newPercentage int)

SetEvictionPercentage sets the new percentage of entries to be evicted when map reaches its capacity When the map is full during insertion, the minimum number of entries to be evicted will be 1

func (*SyncMap) SetMapObj

func (sm *SyncMap) SetMapObj(newMap *map[string]interface{})

SetMapObj sets the whole mapping object directly

type SyncMapWithExpiration

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

SyncMapWithExpiration enhances SyncMap with expiry-tracked cached items.

func NewSyncMapWithExpiration

func NewSyncMapWithExpiration(maxEntries int) *SyncMapWithExpiration

NewSyncMapWithExpiration creates a new SyncMapWithExpiration.

func (*SyncMapWithExpiration) GetEntry

func (sme *SyncMapWithExpiration) GetEntry(key string) (interface{}, bool)

GetEntry gets an active entry.

func (*SyncMapWithExpiration) SetEntry

func (sme *SyncMapWithExpiration) SetEntry(key string, item interface{}, ttl time.Duration)

SetEntry upserts a new cache entry, with the given ttl.

Jump to

Keyboard shortcuts

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