Documentation
¶
Overview ¶
Package core provides the core types used by other Redka packages.
Index ¶
Constants ¶
const ( TypeString = TypeID(1) TypeList = TypeID(2) TypeSet = TypeID(3) TypeHash = TypeID(4) TypeSortedSet = TypeID(5) )
const InitialVersion = 1
InitialVersion is the initial version of the key.
Variables ¶
var ( ErrNotFound = errors.New("key not found") ErrKeyType = errors.New("key type mismatch") // the key already exists with a different type. ErrValueType = errors.New("invalid value type") ErrNotAllowed = errors.New("operation not allowed") )
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
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.