cache

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Foliage statefun cache package. Provides cache system that lives between stateful functions and NATS key/value

Index

Constants

View Source
const (
	KVStorePrefix                               = "store"
	LRUSize                                     = 1000000
	LevelSubscriptionNotificationsBufferMaxSize = 30000 // ~16Mb: elemenets := 16 * 1024 * 1024 / (64 + 512), where 512 - avg value size, 64 - avg key size
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func NewCacheConfig

func NewCacheConfig(id string) *Config

func (*Config) SetKVStorePrefix

func (ro *Config) SetKVStorePrefix(kvStorePrefix string) *Config

func (*Config) SetLRUSize

func (ro *Config) SetLRUSize(lruSize int) *Config

func (*Config) SetLevelSubscriptionNotificationsBufferMaxSize

func (ro *Config) SetLevelSubscriptionNotificationsBufferMaxSize(levelSubscriptionNotificationsBufferMaxSize int) *Config

type KeyValue

type KeyValue struct {
	Key   interface{}
	Value interface{}
}

type Store

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

func NewCacheStore

func NewCacheStore(ctx context.Context, cacheConfig *Config, js nats.JetStreamContext, kv nats.KeyValue) *Store

func (*Store) DeleteValue

func (cs *Store) DeleteValue(key string, updateInKV bool, customDeleteTime int64, transactionID string)

func (*Store) Destroy

func (cs *Store) Destroy()

func (*Store) GetKeysByPattern

func (cs *Store) GetKeysByPattern(pattern string) []string

func (*Store) GetValue

func (cs *Store) GetValue(key string) ([]byte, error)

func (*Store) GetValueAsJSON

func (cs *Store) GetValueAsJSON(key string) (*easyjson.JSON, error)

func (*Store) GetValueUpdateTime

func (cs *Store) GetValueUpdateTime(key string) int64

func (*Store) SetValue

func (cs *Store) SetValue(key string, value []byte, updateInKV bool, customSetTime int64, transactionID string) bool

func (*Store) SetValueIfDoesNotExist

func (cs *Store) SetValueIfDoesNotExist(key string, newValue []byte, updateInKV bool, customSetTime int64) bool

func (*Store) SubscribeLevelCallback

func (cs *Store) SubscribeLevelCallback(key string, callbackID string) chan KeyValue

key - level callback key, for e.g. "a.b.c.*" callbackID - unique id for this subscription

func (*Store) TransactionBegin

func (cs *Store) TransactionBegin(transactionID string)

func (*Store) TransactionEnd

func (cs *Store) TransactionEnd(transactionID string)

func (*Store) UnsubscribeLevelCallback

func (cs *Store) UnsubscribeLevelCallback(key string, callbackID string)

type StoreValue

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

func (*StoreValue) ConsistencyLoss

func (csv *StoreValue) ConsistencyLoss(lossTime int64)

func (*StoreValue) Delete

func (csv *StoreValue) Delete(updateInKV bool, customDeleteTime int64)

func (*StoreValue) GetFullKeyString

func (csv *StoreValue) GetFullKeyString() string

func (*StoreValue) LoadChild

func (csv *StoreValue) LoadChild(key interface{}, safe bool) (*StoreValue, bool)

func (*StoreValue) Lock

func (csv *StoreValue) Lock(caller string)

func (*StoreValue) Put

func (csv *StoreValue) Put(value interface{}, updateInKV bool, customPutTime int64)

func (*StoreValue) Range

func (csv *StoreValue) Range(f func(key, value interface{}) bool)

func (*StoreValue) StoreChild

func (csv *StoreValue) StoreChild(key interface{}, child *StoreValue, safe bool)

func (*StoreValue) TryPurgeConfirm

func (csv *StoreValue) TryPurgeConfirm(safe bool) bool

func (*StoreValue) TryPurgeReady

func (csv *StoreValue) TryPurgeReady(safe bool) bool

func (*StoreValue) Unlock

func (csv *StoreValue) Unlock(caller string)

func (*StoreValue) ValueExists

func (csv *StoreValue) ValueExists() bool

type Transaction

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

type TransactionOperator

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

Jump to

Keyboard shortcuts

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