storage

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeUnknown = iota
	TypeBoolean
	TypeInteger
	TypeInteger8
	TypeInteger16
	TypeInteger32
	TypeInteger64
	TypeUint
	TypeUint8
	TypeUint16
	TypeUint32
	TypeUint64
	TypeFloat32
	TypeFloat64
	TypeString
	TypeDuration
	TypeTime
	TypeBytes
)
View Source
const (
	OptNamespace = iota
	OptKeyPattern
	OptReadable
	OptWritable
	OptTTL
	OptMaxKeyLength   //future use
	OptMaxValueLength //future use
	OptDataTypes      //future use
)

Variables

Functions

func GetType added in v0.0.3

func GetType(v any) int

func GetTypedValue added in v0.0.4

func GetTypedValue(t int, v string, dateFormat string) (any, error)

Types

type Chainable

type Chainable interface {
	//ChainAdapter chains another adapter to this one. If this adapter does not have a value, the chained adapter will be processed
	ChainAdapter(adapter Storage) Storage
	//GetChained returns the chained adapter
	GetChained() Storage
}

type DataTypes

type DataTypes map[int]bool

type Storage

type Storage interface {
	//SetOptions sets the storage options
	SetOptions(opts StorageOptions)
	//GetOptions returns the storage options
	GetOptions() StorageOptions
	//GetItem returns the value for stored item identified by key
	GetItem(key string) (any, error)
	//GetItems sets multiple values.
	GetItems(keys []string) (map[string]any, error)
	//HasItem returns true if storage has the requested key, else false
	HasItem(key string) bool
	//HasItems returns a keyed array of bools denoting if required keys are in the storage
	HasItems(keys []string) map[string]bool
	//SetItem sets the value of the requested key. Returns true if set, else false and a possible error
	SetItem(key string, value any) (bool, error)
	//SetItems sets multiple key values. Returns an array of keys not set and a possible error
	SetItems(values map[string]any) ([]string, error)
	//CheckAndSetItem sets the value of the requested key if the key already exists. Returns true if set, else false and a possible error
	CheckAndSetItem(key string, value any) (bool, error)
	//CheckAndSetItems sets the value of multiple requested keys if the keys already exist. Returns an array of keys not set and a possible error
	CheckAndSetItems(values map[string]any) ([]string, error)
	//TouchItem resets the TTL for the given key. Returns true if reset, else false
	TouchItem(key string) bool
	//TouchItems resets the TTL for multiple keys. Returns an array of keys not reset
	TouchItems(keys []string) []string
	//RemoveItem removes (deletes) the requested key. Returns true if removed, else false
	RemoveItem(key string) bool
	//RemoveItems removes (deletes) multiple key. Returns array of keys not removed
	RemoveItems(keys []string) []string
	//Increment increments the key value by n. If the key is none numeric or not found, an error will be returned
	Increment(key string, n int64) (int64, error)
	//Decrement decrements the key value by n. If the key is none numeric or not found, an error will be returned
	Decrement(key string, n int64) (int64, error)
	//Open opens or starts the adapter
	Open() (Storage, error)
	//Close closes down the adapter
	Close() error
}

type StorageOptions

type StorageOptions map[int]any

Jump to

Keyboard shortcuts

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