storage

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerStore

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

Store implementation using badger

func NewBadgerStore

func NewBadgerStore(path string) (*BadgerStore, error)

(AI GENERATED DESCRIPTION): Initializes a new BadgerStore by opening a Badger database at the specified path and returns the store or an error.

func (*BadgerStore) Begin

func (s *BadgerStore) Begin() (ndn.Store, error)

(AI GENERATED DESCRIPTION): Starts a new write transaction on the BadgerStore and returns a store instance tied to that transaction, panicking if a transaction is already active.

func (*BadgerStore) Close

func (s *BadgerStore) Close() error

(AI GENERATED DESCRIPTION): Closes the underlying Badger database of the store and returns any error.

func (*BadgerStore) Commit

func (s *BadgerStore) Commit() error

(AI GENERATED DESCRIPTION): Commits the current BadgerDB transaction, writing all pending changes to the database and panicking if called when no write transaction is active.

func (*BadgerStore) Get

func (s *BadgerStore) Get(name enc.Name, prefix bool) (wire []byte, err error)

(AI GENERATED DESCRIPTION): Retrieves a value from the Badger store by name, optionally returning the most recent entry that matches a given prefix, and panics if called while a write transaction is active.

func (*BadgerStore) Put

func (s *BadgerStore) Put(name enc.Name, wire []byte) error

(AI GENERATED DESCRIPTION): Stores the supplied packet wire bytes under the key derived from the given name in the Badger database.

func (*BadgerStore) Remove

func (s *BadgerStore) Remove(name enc.Name) error

(AI GENERATED DESCRIPTION): Deletes the record associated with the specified name from the BadgerStore.

func (*BadgerStore) RemoveFlatRange

func (s *BadgerStore) RemoveFlatRange(prefix enc.Name, first enc.Component, last enc.Component) error

(AI GENERATED DESCRIPTION): Deletes all key‑value pairs in the Badger store whose keys fall within the flat name range between the specified first and last components for the given prefix.

func (*BadgerStore) RemovePrefix

func (s *BadgerStore) RemovePrefix(prefix enc.Name) error

(AI GENERATED DESCRIPTION): Deletes all store entries whose keys begin with the given name prefix.

func (*BadgerStore) Rollback

func (s *BadgerStore) Rollback() error

(AI GENERATED DESCRIPTION): Reverts any uncommitted changes in the current transaction by discarding it.

type MemoryFifoDir

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

MemoryFifoDir is a simple object directory that evicts the oldest name when it reaches its size size.

func NewMemoryFifoDir

func NewMemoryFifoDir(size int) *MemoryFifoDir

NewMemoryFifoDir creates a new directory.

func (*MemoryFifoDir) Count

func (d *MemoryFifoDir) Count() int

Count returns the number of names in the directory.

func (*MemoryFifoDir) Evict

func (d *MemoryFifoDir) Evict(client ndn.Client) error

Evict removes old names from a client until it reaches the desired size.

func (*MemoryFifoDir) Pop

func (d *MemoryFifoDir) Pop() enc.Name

Pop removes the oldest name from the directory and returns it. If the directory has not reached its size, it returns nil. It is recommended to use Evict() instead to remove objects from a client.

func (*MemoryFifoDir) Push

func (d *MemoryFifoDir) Push(name enc.Name)

Push adds a name to the directory.

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

(AI GENERATED DESCRIPTION): Creates a new MemoryStore instance initialized with an empty root node.

func (*MemoryStore) Begin

func (s *MemoryStore) Begin() (ndn.Store, error)

(AI GENERATED DESCRIPTION): Begins a transaction on the MemoryStore by initializing a transaction node and locking the transaction mutex.

func (*MemoryStore) Commit

func (s *MemoryStore) Commit() error

(AI GENERATED DESCRIPTION): Commits the pending transaction by merging its changes into the root store and clearing the transaction buffer.

func (*MemoryStore) Get

func (s *MemoryStore) Get(name enc.Name, prefix bool) ([]byte, error)

(AI GENERATED DESCRIPTION): Retrieves the wire‑bytes for the packet named `name`; if `prefix` is true and the exact node has no stored data, it returns the newest descendant packet instead.

func (*MemoryStore) MemSize

func (s *MemoryStore) MemSize() int

(AI GENERATED DESCRIPTION): Returns the total number of bytes used by all packets stored in the MemoryStore by summing the lengths of their wire-encoded representations.

func (*MemoryStore) Put

func (s *MemoryStore) Put(name enc.Name, wire []byte) error

(AI GENERATED DESCRIPTION): Stores the given wire‑encoded data under the specified name in the memory store, using the active transaction if one exists, while protecting the operation with a mutex lock.

func (*MemoryStore) Remove

func (s *MemoryStore) Remove(name enc.Name) error

(AI GENERATED DESCRIPTION): Removes the entry identified by the given name from the in‑memory store.

func (*MemoryStore) RemoveFlatRange

func (s *MemoryStore) RemoveFlatRange(prefix enc.Name, first enc.Component, last enc.Component) error

(AI GENERATED DESCRIPTION): Removes all immediate (flat) child entries of the given prefix whose component keys fall within the inclusive range from `first` to `last`.

func (*MemoryStore) RemovePrefix

func (s *MemoryStore) RemovePrefix(prefix enc.Name) error

(AI GENERATED DESCRIPTION): Removes all entries from the memory store whose names begin with the specified prefix.

func (*MemoryStore) Rollback

func (s *MemoryStore) Rollback() error

(AI GENERATED DESCRIPTION): Reverts any active transaction by clearing the transaction state and releasing the transaction mutex.

Jump to

Keyboard shortcuts

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