cache

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCacheKey

func GenerateCacheKey(method string, encryptionToken string, params ...interface{}) string

GenerateCacheKey generates a cache key for the given method, encryptionToken and parameters encryptionToken is used to generate a unique cache key for each user and empty string should be used for public data

func IsCacheable

func IsCacheable(key *common.RPCRequest, encryptionToken string) (bool, string, time.Duration)

IsCacheable checks if the given RPC request is cacheable and returns the cache key and TTL

Types

type Cache

type Cache interface {
	Set(key string, value map[string]interface{}, ttl time.Duration) bool
	Get(key string) (value map[string]interface{}, ok bool)
}

func NewCache

func NewCache(logger log.Logger) (Cache, error)

type RPCMethodCacheConfig added in v0.22.1

type RPCMethodCacheConfig struct {
	CacheTTL     time.Duration
	RequiresAuth bool
}

Define a struct to hold the cache TTL and auth requirement

type RistrettoCache

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

func NewRistrettoCache

func NewRistrettoCache(logger log.Logger) (*RistrettoCache, error)

NewRistrettoCache returns a new RistrettoCache.

func (*RistrettoCache) Get

func (c *RistrettoCache) Get(key string) (value map[string]interface{}, ok bool)

Get returns the value for the given key if it exists.

func (*RistrettoCache) Set

func (c *RistrettoCache) Set(key string, value map[string]interface{}, ttl time.Duration) bool

Set adds the key and value to the cache.

Jump to

Keyboard shortcuts

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