purekv

package
v0.0.0-...-63beb8f Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default files creation mode
	FileMode = 0700
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

type Heap[T any] struct {
	Data []T
	Comp func(a, b T) bool
}

Heap holds generic heap implementation

func NewHeap

func NewHeap[T any](comp func(a, b T) bool) *Heap[T]

NewHeap creates new instance of Heap, by comparator

func (*Heap[T]) Len

func (h *Heap[T]) Len() int

Len returns size of Heap

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() T

Pop removes and returns top element from Heap

func (*Heap[T]) Push

func (h *Heap[T]) Push(v T)

Push adds new element to Heap

func (*Heap[T]) ViewTop

func (h *Heap[T]) ViewTop() T

ViewTop returns the element from the top of the heap, without removing it

type Store

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

Store is concurrent map

func Load

func Load(path string) (*Store, error)

Load loads store object from disk (shards being loaded in parallel)

func NewStore

func NewStore(shardsNumber, ttlGarbageCollectionTimeoutMs int) *Store

NewStore creates new Store and fills it with empty ConcurrentMaps

func (*Store) Close

func (s *Store) Close()

Close sends exit signal to goroutines that doing background work for the store

func (*Store) Del

func (s *Store) Del(key string)

Del drops value from map by key

func (*Store) DelAll

func (s *Store) DelAll() error

DelAll drops all values from the map

func (*Store) Dump

func (s *Store) Dump(path string) error

Dump serializes buckets and writes them to disk in parallel

func (*Store) Get

func (s *Store) Get(key string) ([]byte, bool)

Get returns value by string key

func (*Store) Has

func (s *Store) Has(key string) bool

Has checks that key is in store

func (*Store) Set

func (s *Store) Set(key string, value []byte, ttlMs int) error

Set places the value in the needed shard by string key

func (*Store) Size

func (s *Store) Size() uint64

Size calculates total size of the map

Jump to

Keyboard shortcuts

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