cache

package
v0.0.0-...-fdc8e6b Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: Unlicense Imports: 7 Imported by: 0

Documentation

Overview

Provide a standardised interface for using our backend caches Insert/InsertTTL should be ran in goroutines to avoid waiting for results Retrieve/TTL functions should return the same error `ErrNotFound` when the key does not exist TTL functions should return `ErrNoExpiry` if they key was found, but no expiry info was found

Index

Constants

This section is empty.

Variables

View Source
var (
	RetrieveKV  = storage.RetrieveKV
	RetrieveGob = storage.RetrieveGob
	ErrNotFound = storage.ErrNotFound
)
View Source
var (
	ErrNoExpiry = errors.New("key does not have an associated Expiry/TTL")
)

Errors

Functions

func InsertGob

func InsertGob(cache Cache, key string, e interface{}, ttl time.Duration) error

func InsertKV

func InsertKV(cache Cache, key, value string, ttl time.Duration) error

Types

type Cache

type Cache interface {
	// Name returns the CacheConfig Name
	Name() string
	// Implements storage.Storage interface
	storage.Storage
	// InsertTTL inserts a new value into the store with the given expiry
	InsertTTL(key string, value []byte, ttl time.Duration) error
	// TTL returns the existing TTL for a key and an optional error
	// The expectation is that the Cache will handle whether this is a
	TTL(key string) (time.Duration, error)
	// Start the cache / expiry tracker
	Start()
	// Stop the cache / expiry tracker
	Stop()
}

type CacheConfig

type CacheConfig struct {
	Name   string
	Logger util_log.Logger
}

func (*CacheConfig) RegisterFlags

func (c *CacheConfig) RegisterFlags(f *flag.FlagSet, cacheID string)

Directories

Path Synopsis
Migrate from bolt to badger
Migrate from bolt to badger
util
expiry
Common methods for Expiry packages Common methods for Expiry packages
Common methods for Expiry packages Common methods for Expiry packages
expiry/memory
memory is a thread safe library for handling TTL of keys as an expiry solution, `memory` is only suitable of in-memory store as the exoiry records do not persist
memory is a thread safe library for handling TTL of keys as an expiry solution, `memory` is only suitable of in-memory store as the exoiry records do not persist
expiry/store
Implement expiry within the the actual value storage The underlying store will need to use this when Inserting/Retrieving
Implement expiry within the the actual value storage The underlying store will need to use this when Inserting/Retrieving

Jump to

Keyboard shortcuts

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