keys

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: GPL-3.0 Imports: 7 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CrazyKey

func CrazyKey() hsk.Key

CrazyKey is a short-hand for NewKey(-1), returns old date

func NewKey

func NewKey(nextID int64) hsk.Key

NewKey creates a new key with the current time as the Stamp

func NewKeyWithTime

func NewKeyWithTime(timestamp, nextID int64) hsk.Key

func ParseKey

func ParseKey(rawKey string) (hsk.Key, error)

ParseKey tries to parse EPOCH`00 Keys.

Types

type TimeKey

type TimeKey struct {
	//Stamp is the EPOCH Creation Time
	Stamp int64
	//ID increments with duplicate Stamps
	ID int64
}

TimeKey is the Primary Key for Husk Indexes. It orders records by Timestamp

func (*TimeKey) Compare

func (k *TimeKey) Compare(obj interface{}) int8

Compare returns -1 (smaller), 0 (equal), 1 (larger)

func (TimeKey) GetTimestamp

func (k TimeKey) GetTimestamp() time.Time

GetTimestamp returns the creation time of the record

func (TimeKey) MarshalJSON

func (k TimeKey) MarshalJSON() ([]byte, error)

MarshalJSON will return a Key as {stamp}`{key}

func (TimeKey) String

func (k TimeKey) String() string

String returns the string representation for a Key, also makes is easier to parse.

func (*TimeKey) UnmarshalJSON

func (k *TimeKey) UnmarshalJSON(b []byte) error

UnmarshalJSON will return {stamp}`{key} as a Key

Jump to

Keyboard shortcuts

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