memory

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	GCInterval: 10 * time.Second,
}

ConfigDefault is the default config

Functions

This section is empty.

Types

type Config

type Config struct {
	// Time before deleting expired keys
	//
	// Default is 10 * time.Second
	GCInterval time.Duration
}

Config defines the config for storage.

type Memory

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

Memory interface that is implemented by storage providers

func New

func New(config ...Config) *Memory

New creates a new memory storage

func (*Memory) Close

func (s *Memory) Close() error

Close the memory storage

func (*Memory) Conn

func (s *Memory) Conn() map[string]entry

Conn database client

func (*Memory) Connection

func (s *Memory) Connection(name string) storage.Storage

func (*Memory) Delete

func (s *Memory) Delete(key string) error

Delete key by key

func (*Memory) DeleteByPrefix

func (s *Memory) DeleteByPrefix(prefix []byte)

func (*Memory) Get

func (s *Memory) Get(key string) ([]byte, error)

Get value by key

func (*Memory) Iterate

func (s *Memory) Iterate(fn func(key []byte, value []byte))

func (*Memory) IterateByPrefix

func (s *Memory) IterateByPrefix(prefix []byte, limit uint64, fn func(key []byte, value []byte)) uint64

func (*Memory) IterateByPrefixFrom

func (s *Memory) IterateByPrefixFrom(prefix []byte, from []byte, limit uint64, fn func(key []byte, value []byte)) uint64

func (*Memory) KeysByPrefixCount

func (s *Memory) KeysByPrefixCount(prefix []byte) uint64

func (*Memory) Reset

func (s *Memory) Reset() error

Reset all keys

func (*Memory) Set

func (s *Memory) Set(key string, val []byte, exp time.Duration) error

Set key with value

Jump to

Keyboard shortcuts

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