storage

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Count = 256 // Don't edit!
)

Variables

View Source
var (
	NotFoundError = errors.New("not found")
	TypeCastError = errors.New("fail cast to []byte")
)

Functions

func BulkStore added in v0.2.0

func BulkStore(entries []*Entry)

BulkStore store array Entry

func Clear added in v0.2.0

func Clear()

Clear clearing storage from expired values

func Delete added in v0.2.0

func Delete(key string)

Delete Entry

func Store

func Store(e *Entry)

Store Entry

Types

type Entry

type Entry struct {
	Key   string
	Value []byte
	// contains filtered or unexported fields
}

func Load

func Load(key string) (*Entry, error)

Load Entry

func NewEntry

func NewEntry[T Ttl](key string, value []byte, ttl T) *Entry

func (*Entry) HasExpired

func (e *Entry) HasExpired() bool

type ExpiredFunction added in v0.2.0

type ExpiredFunction func(t time.Time, ttl time.Duration) bool

type Storage added in v0.2.0

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

func (*Storage) AllEntries added in v0.2.0

func (s *Storage) AllEntries() []*Entry

func (*Storage) Clear added in v0.2.0

func (s *Storage) Clear()

func (*Storage) Delete added in v0.2.0

func (s *Storage) Delete(key string)

func (*Storage) Load added in v0.2.0

func (s *Storage) Load(key string) (*Entry, error)

func (*Storage) Store added in v0.2.0

func (s *Storage) Store(entry *Entry)

type Ttl added in v0.2.0

type Ttl interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64
}

Jump to

Keyboard shortcuts

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