objectstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package objectstore defines an interface between the helium services and the session data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBadgerObjectStore

func NewBadgerObjectStore(conf Config) (ks *badgerObjectStore, err error)

NewBadgerObjectStore creates a new ObjectStore instance.

func NewHybridObjectStore

func NewHybridObjectStore(conf Config) (*hybridObjectStore, error)

NewHybridObjectStore creates a new ObjectStore instance.

func NewMemObjectStore

func NewMemObjectStore() *memObjectStore

NewMemObjectStore creates a new ObjectStore instance.

func NewNullObjectStore

func NewNullObjectStore() *nullObjectStore

NewNullObjectStore creates a new ObjectStore instance.

Types

type Config

type Config struct {
	BackendName string // BackendName is a string defining the ObjectStore implementation to use.
	DBPath      string
}

Config represents the ObjectStore configuration.

type ObjectStore

type ObjectStore interface {
	// Store stores the binary-serializable `object` into the ObjectStore indexing it with the string `objectID`.
	Store(objectID string, object encoding.BinaryMarshaler) error

	// Load loads the binary-deserializable `object` from the ObjectStore indexing it with the string `objectID`.
	// the result is loaded directly into `object`
	Load(objectID string, object encoding.BinaryUnmarshaler) error

	// IsPresent checks if the object indexed with the string `objectID` is present in the ObjectStore.
	IsPresent(objectID string) (bool, error)

	// Close releases the resources allocated by the ObjectStore.
	Close() error
}

ObjectStore is an interface to store and retrieve session data.

func NewObjectStoreFromConfig

func NewObjectStoreFromConfig(config Config) (objs ObjectStore, err error)

NewObjectStoreFromConfig creates a new ObjectStore instance from the given Config. It accepts the following store backends: - "null": a no-op store that does nothing. - "mem": an in-memory store. - "badgerdb": a persistent store using BadgerDB. - "hybrid": a store that combines an in-memory and a persistent store.

Jump to

Keyboard shortcuts

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