cache

package
v0.0.0-...-3c4c4c4 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRemoteCacheObjectRev

func GetRemoteCacheObjectRev(in RemoteCacheObject) string

Types

type Cache

type Cache[K comparable, T any] interface {
	Get(ctx context.Context, key K) (T, error)
	Invalidate(key K)
}

func NewCache

func NewCache[K comparable, T any](extract CacheExtract[K, T]) Cache[K, T]

func NewCacheWithTTL

func NewCacheWithTTL[K comparable, T any](extract CacheExtract[K, T], maxTTL time.Duration) Cache[K, T]

type CacheExtract

type CacheExtract[K comparable, T any] func(ctx context.Context, in K) (T, time.Time, error)

type ConfigFile

type ConfigFile[T any] interface {
	Get(ctx context.Context) (T, string, error)
}

func NewConfigFile

func NewConfigFile[T any](path string, ttl time.Duration) ConfigFile[T]

type Hash

type Hash interface {
	Hash() string
}

type HashCache

type HashCache[K Hash, T any] interface {
	Get(ctx context.Context, key K) (T, error)
}

func NewHashCache

func NewHashCache[K Hash, T any](extract HashCacheExtract[K, T]) HashCache[K, T]

type HashCacheExtract

type HashCacheExtract[K Hash, T any] func(ctx context.Context, in K) (T, time.Time, error)

type HashedConfiguration

type HashedConfiguration[T any] interface {
	Get(ctx context.Context) (T, error)
}

func NewHashedConfiguration

func NewHashedConfiguration[T, S any](config ConfigFile[S], retriever HashedConfigurationRetriever[T, S]) HashedConfiguration[T]

type HashedConfigurationRetriever

type HashedConfigurationRetriever[T, S any] func(ctx context.Context, in S) (T, error)

type Object

type Object[T any] interface {
	Get(ctx context.Context) (T, error)
}

func NewObject

func NewObject[T any](caller ObjectFetcher[T]) Object[T]

type ObjectFetcher

type ObjectFetcher[T any] func(ctx context.Context) (T, time.Duration, error)

type RemoteCache

type RemoteCache[T RemoteCacheObject] interface {
	// Put puts the key in the cache
	Put(ctx context.Context, key string, obj T) error

	// Get gets the key from the cache
	// Returns T, Exists, Error
	Get(ctx context.Context, key string) (T, bool, error)

	// Remove removed the key from the cache
	// Returns Removed, Error
	Remove(ctx context.Context, key string) (bool, error)

	// Invalidate invalidates internal cache
	Invalidate(ctx context.Context, key string)

	// List lists the keys matching predicate from the server
	// Always misses the cache
	List(ctx context.Context, size int, prefix string) (util.NextIterator[[]string], error)
}

func NewRemoteCache

func NewRemoteCache[T RemoteCacheObject](collection Object[arangodb.Collection]) RemoteCache[T]

func NewRemoteCacheWithTTL

func NewRemoteCacheWithTTL[T RemoteCacheObject](collection Object[arangodb.Collection], ttl time.Duration) RemoteCache[T]

type RemoteCacheObject

type RemoteCacheObject interface {
	SetKey(string)
	GetKey() string

	Expires() time.Time
}

type RemoteCacheObjectRev

type RemoteCacheObjectRev interface {
	RemoteCacheObject

	GetRev() string
}

Jump to

Keyboard shortcuts

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