storage

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Atomic added in v2.2.10

func Atomic(function func())

Atomic execution of storage access. Useful when loading of a old key is needed to update it based on the value

func Delete

func Delete(collection string, key string) error

Delete will return a single entry of a collection

func DeleteCollection

func DeleteCollection(collection string) error

DeleteCollection delete all entries of a collection

func GetKeys

func GetKeys(collection string) ([]string, error)

GetKeys will return the (json) strings of a collection

func InitStorage

func InitStorage(path string) error

InitStorage registers a local directory as JSON file Storage

func Read

func Read(collection string, key string, v any) error

Read will load the stored data for one entry (using reference) to avoid allocation

func SetStorage

func SetStorage(storage Storage)

SetStorage provide Storage to persist data for bot usage

func Write

func Write(collection string, key string, v any) error

Write stores one value in the persistent Storage

Types

type Storage

type Storage interface {
	Write(collection, key string, v any) error
	Read(collection, key string, v any) error
	GetKeys(collection string) ([]string, error)
	Delete(collection, key string) error
}

Storage is the main interface which is used to persist bot related data (like queued messages or user histories)

func NewChainStorage added in v2.2.10

func NewChainStorage(persistent Storage, memory Storage) Storage

NewChainStorage combines two storages to have a persistent and fast a memory storage

func NewRedisStorage

func NewRedisStorage(client *redis.Client) Storage

NewRedisStorage defined a redis bases storage to persist bot related information

Jump to

Keyboard shortcuts

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