Documentation
¶
Index ¶
- func AddModelIndexes(catalog *coal.Catalog, removeAfter time.Duration)
- func Del(ctx context.Context, store *coal.Store, value Value) (bool, error)
- func DelLocked(ctx context.Context, store *coal.Store, value Value) (bool, error)
- func Get(ctx context.Context, store *coal.Store, value Value) (bool, error)
- func GetKey(value Value) (string, error)
- func GetLocked(ctx context.Context, store *coal.Store, value Value) (bool, error)
- func Lock(ctx context.Context, store *coal.Store, value Value, timeout time.Duration) (bool, error)
- func Mut(ctx context.Context, store *coal.Store, value Value, fn func(bool) error) error
- func MutLocked(ctx context.Context, store *coal.Store, value Value, fn func(bool) error) error
- func Set(ctx context.Context, store *coal.Store, value Value) (bool, error)
- func SetLocked(ctx context.Context, store *coal.Store, value Value) (bool, error)
- func Unlock(ctx context.Context, store *coal.Store, value Value) (bool, error)
- type Base
- type ExtendedValue
- type Meta
- type Model
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddModelIndexes ¶ added in v0.28.0
AddModelIndexes will add required indexes to the specified catalog. If remove after is specified, values are automatically removed when their deadline timestamp falls behind the specified duration.
func Del ¶
Del will remove the specified value from the store. This method will ignore any locks held on the value.
func Get ¶
Get will load the contents of the specified value. It will also return whether the value exists at all.
func Lock ¶
Lock will lock and read the specified value. Lock may create a new value in the process and lock it right away. It will also update the deadline of the value if a time to live is set.
func Mut ¶ added in v0.26.0
Mut will load the specified value, run the callback and on success write the value back. This method will ignore any locks held on the value.
func MutLocked ¶ added in v0.26.0
MutLocked will load the specified value, run the callback and on success write the value back.
func Set ¶
Set will write the specified value to the store and overwrite any existing data. It will return if a new value has been created in the process. This method will ignore any locks held on the value.
Types ¶
type Base ¶ added in v0.28.0
Base can be embedded in a struct to turn it into a value.
func (*Base) GetAccessor ¶ added in v0.28.0
GetAccessor implements the Value interface.
type ExtendedValue ¶ added in v0.28.0
ExtendedValue is a value that can extends its key.
type Meta ¶ added in v0.28.0
type Meta struct {
// The values type.
Type reflect.Type
// The values key.
Key string
// The values time to live.
TTL time.Duration
// The used transfer coding.
Coding stick.Coding
// The accessor.
Accessor *stick.Accessor
}
Meta contains meta information about a value.
type Model ¶ added in v0.28.0
type Model struct {
coal.Base `json:"-" bson:",inline" coal:"values"`
// The key of the value.
Key string `json:"key"`
// The content of the value.
Data stick.Map `json:"data"`
// The time after the value can be deleted.
Deadline *time.Time `json:"deadline"`
// The time until the value is locked.
Locked *time.Time `json:"locked"`
// The token used to lock the value.
Token *coal.ID `json:"token"`
}
Model stores an encoded value.