vstore

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("key: not found")
)

Functions

This section is empty.

Types

type ValueRecord

type ValueRecord struct {
	AddedAt int64         // When was the record added
	TTL     int64         // The time to live of the record
	TTLUnit time.Duration // Duration multiplier
	// contains filtered or unexported fields
}

func NewValueRecord

func NewValueRecord(key []byte, value []byte, addedAt int64, ttl int64, ttlUnit time.Duration) *ValueRecord

func (*ValueRecord) HasExpired

func (vr *ValueRecord) HasExpired() bool

type ValueStore

type ValueStore struct {
	KVStore map[string]*ValueRecord // The backing datastore
	// contains filtered or unexported fields
}

func NewValueStore

func NewValueStore(ttl int64, ttlUnit time.Duration) *ValueStore

func (*ValueStore) Get

func (vs *ValueStore) Get(key []byte) ([]byte, error)

func (*ValueStore) PruneOld

func (vs *ValueStore) PruneOld()

func (*ValueStore) PruneWorker

func (vs *ValueStore) PruneWorker()

func (*ValueStore) Put

func (vs *ValueStore) Put(key []byte, value []byte) error

Jump to

Keyboard shortcuts

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