Documentation ¶
Overview ¶
Package core provides the core types used by other Redka packages.
Index ¶
Constants ¶
Variables ¶
var ( ErrKeyType = errors.New("key type mismatch") // the key already exists with a different type ErrNotAllowed = errors.New("operation not allowed") ErrNotFound = errors.New("key or elem not found") ErrValueType = errors.New("invalid value type") )
Common errors returned by data structure methods.
Functions ¶
func IsValueType ¶
IsValueType reports if the value has a valid type to be persisted in the database. Only the following types are allowed:
- string
- integer
- float
- boolean
- byte slice
func ToBytesMany ¶ added in v0.4.0
ToBytesMany converts multiple values to byte slices.
Types ¶
type Key ¶
type Key struct { ID int Key string Type TypeID Version int // incremented on each update ETime *int64 // expiration time in unix milliseconds MTime int64 // last modification time in unix milliseconds }
Key represents a key data structure. Each key uniquely identifies a data structure stored in the database (e.g. a string, a list, or a hash). There can be only one data structure with a given key, regardless of type. For example, you can't have a string and a hash map with the same key.
type TypeID ¶ added in v0.2.0
type TypeID int
A TypeID identifies the type of the key and thus the data structure of the value with that key.
type Value ¶
type Value []byte
Value represents a value stored in a database (a byte slice). It can be converted to other scalar types.
func (Value) MustBool ¶
MustBool returns the value as a boolean, and panics if the value is not a valid boolean. Use this method only if you are sure of the value type.
func (Value) MustFloat ¶
MustFloat returns the value as a float64, and panics if the value is not a valid float. Use this method only if you are sure of the value type.