kvstore

package
v0.0.0-...-bd01111 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedKeyValueStore

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

CachedKeyValueStore is a key-value that all reads from the underlying store.

func NewCachedKeyValueStore

func NewCachedKeyValueStore(kv lib.KeyValueStore) *CachedKeyValueStore

NewCachedKeyValueStore creates a new CachedKeyValueStore.

func (*CachedKeyValueStore) Get

Get gets the value for a key from either the cache or the underlying store. If the value is not in the cache, it is read from the underlying store and cached.

func (*CachedKeyValueStore) Set

func (c *CachedKeyValueStore) Set(key, value common.Hash)

Set sets a key-value pair in the store. The write is NOT cached.

type HashedMemoryKeyValueStore

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

HashedMemoryKeyValueStore is an in-memory key-value store that hashes keys before storing them.

func NewHashedMemoryKeyValueStore

func NewHashedMemoryKeyValueStore() *HashedMemoryKeyValueStore

NewHashedMemoryKeyValueStore creates a new HashedMemoryKeyValueStore.

func (*HashedMemoryKeyValueStore) Delete

func (kv *HashedMemoryKeyValueStore) Delete(key common.Hash)

Delete deletes a key from the store.

func (*HashedMemoryKeyValueStore) DeleteByKeyHash

func (kv *HashedMemoryKeyValueStore) DeleteByKeyHash(keyHash common.Hash)

DeleteByKeyHash deletes a key from the store using the key hash.

func (*HashedMemoryKeyValueStore) ForEach

func (kv *HashedMemoryKeyValueStore) ForEach(forEach func(keyHash, value common.Hash) bool)

ForEach calls a function for each key-value pair in the store.

func (*HashedMemoryKeyValueStore) Get

Get gets the value for a key from the store.

func (*HashedMemoryKeyValueStore) GetByKeyHash

func (kv *HashedMemoryKeyValueStore) GetByKeyHash(keyHash common.Hash) common.Hash

GetByKeyHash gets the value for a key from the store using the key hash.

func (*HashedMemoryKeyValueStore) Has

Has checks if a key exists in the store.

func (*HashedMemoryKeyValueStore) HasByKeyHash

func (kv *HashedMemoryKeyValueStore) HasByKeyHash(keyHash common.Hash) bool

HasByKeyHash checks if a key exists in the store using the key hash.

func (*HashedMemoryKeyValueStore) Set

func (kv *HashedMemoryKeyValueStore) Set(key common.Hash, value common.Hash)

Set sets a key-value pair in the store.

func (*HashedMemoryKeyValueStore) SetByKeyHash

func (kv *HashedMemoryKeyValueStore) SetByKeyHash(keyHash, value common.Hash)

SetByKeyHash sets a key-value pair in the store using the key hash.

func (*HashedMemoryKeyValueStore) Size

func (kv *HashedMemoryKeyValueStore) Size() int

Size returns the number of key-value pairs in the store.

type MemoryKeyValueStore

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

KeyValueStore is an in-memory key-value store.

func NewMemoryKeyValueStore

func NewMemoryKeyValueStore() *MemoryKeyValueStore

NewMemoryKeyValueStore creates a new MemoryKeyValueStore.

func (*MemoryKeyValueStore) Delete

func (kv *MemoryKeyValueStore) Delete(key common.Hash)

Delete deletes a key from the store.

func (*MemoryKeyValueStore) ForEach

func (kv *MemoryKeyValueStore) ForEach(forEach func(key, value common.Hash) bool)

ForEach calls a function for each key-value pair in the store.

func (*MemoryKeyValueStore) Get

func (kv *MemoryKeyValueStore) Get(key common.Hash) common.Hash

Get gets the value for a key from the store.

func (*MemoryKeyValueStore) Has

func (kv *MemoryKeyValueStore) Has(key common.Hash) bool

Has checks if a key exists in the store.

func (*MemoryKeyValueStore) Set

func (kv *MemoryKeyValueStore) Set(key common.Hash, value common.Hash)

Set sets a key-value pair in the store.

func (*MemoryKeyValueStore) Size

func (kv *MemoryKeyValueStore) Size() int

Size returns the number of key-value pairs in the store.

type StagedKeyValueStore

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

StagedKeyValueStore is a key-value store that stages writes to the underlying store until commit is called.

func NewStagedKeyValueStore

func NewStagedKeyValueStore(kv lib.KeyValueStore) *StagedKeyValueStore

NewStagedKeyValueStore creates a new StagedKeyValueStore.

func (*StagedKeyValueStore) Commit

func (s *StagedKeyValueStore) Commit()

Commit writes the staged key-value pairs to the underlying store.

func (*StagedKeyValueStore) Get

Get gets the value for a key from the store. If the key is staged, the staged value is returned.

func (*StagedKeyValueStore) Revert

func (s *StagedKeyValueStore) Revert()

Revert discards the staged key-value pairs.

func (*StagedKeyValueStore) Set

func (s *StagedKeyValueStore) Set(key, value common.Hash)

Set stages a key-value pair to be written to the underlying store on commit.

Jump to

Keyboard shortcuts

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