Documentation ¶
Index ¶
- Constants
- func BytesToTimeUTC(b []byte) (t time.Time)
- func DeepBucket(tx *bolt.Tx, elements ...[]byte) (bucket *bolt.Bucket)
- func DeepCreateBucketIfNotExists(tx *bolt.Tx, elements ...[]byte) (bucket *bolt.Bucket, err error)
- func DeepDelete(tx *bolt.Tx, ensure bool, elements ...[]byte) (err error)
- func DeepDeleteBucket(tx *bolt.Tx, ensure bool, elements ...[]byte) (err error)
- func DeepGet(tx *bolt.Tx, elements ...[]byte) (data []byte)
- func DeepPut(tx *bolt.Tx, overwrite bool, elements ...[]byte) (new bool, err error)
- func IsExistsError(err error) (yes bool)
- func IsNotFoundError(err error) (yes bool)
- func Natural(in string) (out string)
- func PutTimeToBytesUTC(b []byte, t time.Time)
- func TimeToBytesUTC(t time.Time) (b []byte)
- type ExistsError
- type NotFoundError
Constants ¶
const TimeBytesLen = 9
TimeBytesLen is the length of byte slice time representation returned by TimeToBytesUTC.
Variables ¶
This section is empty.
Functions ¶
func BytesToTimeUTC ¶ added in v0.2.2
BytesToTimeUTC converts slice of bytes as described in TimeToBytesUTC to time.Time.
func DeepBucket ¶ added in v0.2.1
DeepBucket retrieves bucket named as the last element of the elements arguments in nested buckets named as previous elements.
func DeepCreateBucketIfNotExists ¶ added in v0.2.1
DeepCreateBucketIfNotExists creates nested buckets with names of the elements arguments.
func DeepDelete ¶ added in v0.2.0
DeepDelete deletes the key named as the last element of the elements arguments in nested buckets named as previous elements. With argument set to true, this function will return ErrNotFound if the element is not deleted.
func DeepDeleteBucket ¶ added in v0.2.1
DeepDeleteBucket deletes bucket named as the last element of the elements arguments in nested buckets named as previous elements. With argument set to true, this function will return ErrNotFound if the element is not deleted.
func DeepGet ¶ added in v0.2.0
DeepGet retrieves the key named as the last element of the elements arguments in nested buckets named as previous elements.
func DeepPut ¶ added in v0.2.0
DeepPut saves the last element of elements arguments under the key named by the second to last element, and all previous elements will be created as buckets if any of them do not exist. With overwrite argument set to false, this function will return ErrExists if the element already exists. Return value new will be true if element is put for the first time.
func IsExistsError ¶ added in v0.2.0
IsExistsError returns true if provided error is of ExistsError type.
func IsNotFoundError ¶ added in v0.2.0
IsNotFoundError returns true if provided error is of NotFoundError type.
func Natural ¶ added in v0.4.1
Natural returns a string suitable for natural sort ordering. All numbers are encoded in big endian binary representation.
func PutTimeToBytesUTC ¶ added in v0.2.2
PutTimeToBytesUTC puts bytes represention if provided time to provide slice. The slice must have length of 9 bytes.
func TimeToBytesUTC ¶ added in v0.2.2
TimeToBytesUTC returns slice of bytes that represent provided time in UTC. Slice length is always 9, where first 2 bytes represent the year and the rest 7 bytes nanoseconds since the begining the year. This representation is compact, can represent year range from -math.MaxInt16 to math.MaxInt16 and is sortable. Even it is not related to Bolt, it can be used to sort keys by timestamp in a compact representation.
Types ¶
type ExistsError ¶ added in v0.2.0
type ExistsError struct {
Key string
}
ExistsError is retuned by DeepPut if overwrite option is set to false.
func NewExistsError ¶ added in v0.2.0
func NewExistsError(key string) *ExistsError
NewExistsError returns a new instance of ExistsError.
func (*ExistsError) Error ¶ added in v0.2.0
func (e *ExistsError) Error() string
type NotFoundError ¶ added in v0.2.0
type NotFoundError struct {
Key string
}
NotFoundError is returned by DeepDelete if ensure options is true.
func NewNotFoundError ¶ added in v0.2.0
func NewNotFoundError(key string) *NotFoundError
NewNotFoundError returns a new instance of NotFoundError.
func (*NotFoundError) Error ¶ added in v0.2.0
func (e *NotFoundError) Error() string