Documentation
¶
Index ¶
- Constants
- Variables
- func WithTransaction(ctx context.Context, beanName string, tx Transaction) context.Context
- type CompareAndSetOperation
- func (t *CompareAndSetOperation) Binary(value []byte) (bool, error)
- func (t *CompareAndSetOperation) ByKey(formatKey string, args ...interface{}) *CompareAndSetOperation
- func (t *CompareAndSetOperation) ByRawKey(key []byte) *CompareAndSetOperation
- func (t *CompareAndSetOperation) Counter(value uint64) (bool, error)
- func (t *CompareAndSetOperation) Proto(msg proto.Message) (bool, error)
- func (t *CompareAndSetOperation) String(value string) (bool, error)
- func (t *CompareAndSetOperation) WithTtl(ttlSeconds int) *CompareAndSetOperation
- func (t *CompareAndSetOperation) WithVersion(version int64) *CompareAndSetOperation
- type DataStore
- type DataStoreManager
- type EnumerateOperation
- func (t *EnumerateOperation) ByPrefix(formatPrefix string, args ...interface{}) *EnumerateOperation
- func (t *EnumerateOperation) ByRawPrefix(prefix []byte) *EnumerateOperation
- func (t *EnumerateOperation) Do(cb func(*RawEntry) bool) error
- func (t *EnumerateOperation) DoProto(factory func() proto.Message, cb func(*ProtoEntry) bool) error
- func (t *EnumerateOperation) OnlyKeys() *EnumerateOperation
- func (t *EnumerateOperation) Reverse() *EnumerateOperation
- func (t *EnumerateOperation) Seek(formatSeek string, args ...interface{}) *EnumerateOperation
- func (t *EnumerateOperation) WithBatchSize(batchSize int) *EnumerateOperation
- type GetOperation
- func (t *GetOperation) ByKey(formatKey string, args ...interface{}) *GetOperation
- func (t *GetOperation) ByRawKey(key []byte) *GetOperation
- func (t *GetOperation) Required() *GetOperation
- func (t *GetOperation) ToBinary() ([]byte, error)
- func (t *GetOperation) ToCounter() (uint64, error)
- func (t *GetOperation) ToEntry() (entry RawEntry, err error)
- func (t *GetOperation) ToProto(container proto.Message) error
- func (t *GetOperation) ToProtoEntry(factory func() proto.Message) (entry ProtoEntry, err error)
- func (t *GetOperation) ToString() (string, error)
- type IncrementOperation
- func (t *IncrementOperation) ByKey(formatKey string, args ...interface{}) *IncrementOperation
- func (t *IncrementOperation) ByRawKey(key []byte) *IncrementOperation
- func (t *IncrementOperation) Do() (prev int64, err error)
- func (t *IncrementOperation) WithDelta(delta int64) *IncrementOperation
- func (t *IncrementOperation) WithInitialValue(initial int64) *IncrementOperation
- func (t *IncrementOperation) WithTtl(ttlSeconds int) *IncrementOperation
- type ManagedDataStore
- type ManagedTransactionalDataStore
- type ProtoEntry
- type RawEntry
- type RemoveOperation
- type SetOperation
- func (t *SetOperation) Binary(value []byte) error
- func (t *SetOperation) ByKey(formatKey string, args ...interface{}) *SetOperation
- func (t *SetOperation) ByRawKey(key []byte) *SetOperation
- func (t *SetOperation) Counter(value uint64) error
- func (t *SetOperation) Proto(msg proto.Message) error
- func (t *SetOperation) String(value string) error
- func (t *SetOperation) WithTtl(ttlSeconds int) *SetOperation
- type Transaction
- type TransactionalDataStore
- type TransactionalManager
Constants ¶
View Source
const NoTTL = 0
* Marker that TTL (time-to-live in seconds) is not defined, therefore not setup, meaning eternal record
Variables ¶
View Source
var ( ErrNotFound = os.ErrNotExist // ErrInvalidRequest is returned if the user request is invalid. ErrInvalidRequest = errors.New("invalid request") // ErrConcurrentTransaction is returned when a transaction conflicts with another transaction. ErrConcurrentTxn = errors.New("concurrent transaction, try again") // ErrReadOnlyTxn is returned if an update function is called on a read-only transaction. ErrReadOnlyTxn = errors.New("read-only transaction has update operation") // ErrDiscardedTxn is returned if a previously discarded transaction is re-used. ErrDiscardedTxn = errors.New("transaction has been discarded") // ErrCanceledTxn is returned if user canceled transaction. ErrCanceledTxn = errors.New("transaction has been canceled") // ErrTooBigTxn is returned if too many writes are fit into a single transaction. ErrTooBigTxn = errors.New("transaction is too big") // ErrEmptyKey is returned if an empty key is passed on an update function. ErrEmptyKey = errors.New("empty key") // ErrInvalidKey is returned if the key has wrong character(s) ErrInvalidKey = errors.New("key is invalid") // ErrAlreadyClosed is returned when fastfood is already closed ErrAlreadyClosed = errors.New("already closed") // ErrInternal ErrInternal = errors.New("internal error") )
View Source
var DataStoreClass = reflect.TypeOf((*DataStore)(nil)).Elem()
View Source
var DataStoreManagerClass = reflect.TypeOf((*DataStoreManager)(nil)).Elem()
View Source
var DefaultBatchSize = 256
* Default batch size, could be overwritten
View Source
var ManagedDataStoreClass = reflect.TypeOf((*ManagedDataStore)(nil)).Elem()
View Source
var ManagedTransactionalDataStoreClass = reflect.TypeOf((*ManagedTransactionalDataStore)(nil)).Elem()
View Source
var TransactionClass = reflect.TypeOf((*Transaction)(nil)).Elem()
View Source
var TransactionalDataStoreClass = reflect.TypeOf((*TransactionalDataStore)(nil)).Elem()
View Source
var TransactionalManagerClass = reflect.TypeOf((*TransactionalManager)(nil)).Elem()
Functions ¶
func WithTransaction ¶
Types ¶
type CompareAndSetOperation ¶
type CompareAndSetOperation struct { DataStore // should be initialized Context context.Context // should be initialized // contains filtered or unexported fields }
func (*CompareAndSetOperation) Binary ¶
func (t *CompareAndSetOperation) Binary(value []byte) (bool, error)
func (*CompareAndSetOperation) ByKey ¶
func (t *CompareAndSetOperation) ByKey(formatKey string, args ...interface{}) *CompareAndSetOperation
func (*CompareAndSetOperation) ByRawKey ¶
func (t *CompareAndSetOperation) ByRawKey(key []byte) *CompareAndSetOperation
func (*CompareAndSetOperation) Counter ¶
func (t *CompareAndSetOperation) Counter(value uint64) (bool, error)
func (*CompareAndSetOperation) Proto ¶
func (t *CompareAndSetOperation) Proto(msg proto.Message) (bool, error)
func (*CompareAndSetOperation) String ¶
func (t *CompareAndSetOperation) String(value string) (bool, error)
func (*CompareAndSetOperation) WithTtl ¶
func (t *CompareAndSetOperation) WithTtl(ttlSeconds int) *CompareAndSetOperation
func (*CompareAndSetOperation) WithVersion ¶
func (t *CompareAndSetOperation) WithVersion(version int64) *CompareAndSetOperation
type DataStore ¶
type DataStore interface { gluten.DisposableBean gluten.NamedBean Get(ctx context.Context) *GetOperation Set(ctx context.Context) *SetOperation // equivalent of i++ operation, always returns previous value Increment(ctx context.Context) *IncrementOperation CompareAndSet(ctx context.Context) *CompareAndSetOperation Remove(ctx context.Context) *RemoveOperation Enumerate(ctx context.Context) *EnumerateOperation GetRaw(ctx context.Context, key []byte, ttlPtr *int, versionPtr *int64, required bool) ([]byte, error) SetRaw(ctx context.Context, key, value []byte, ttlSeconds int) error CompareAndSetRaw(ctx context.Context, key, value []byte, ttlSeconds int, version int64) (bool, error) IncrementRaw(ctx context.Context, key []byte, initial, delta int64, ttlSeconds int) (int64, error) RemoveRaw(ctx context.Context, key []byte) error EnumerateRaw(ctx context.Context, prefix, seek []byte, batchSize int, onlyKeys bool, reverse bool, cb func(*RawEntry) bool) error }
type DataStoreManager ¶
type EnumerateOperation ¶
type EnumerateOperation struct { DataStore // should be initialized Context context.Context // should be initialized // contains filtered or unexported fields }
func (*EnumerateOperation) ByPrefix ¶
func (t *EnumerateOperation) ByPrefix(formatPrefix string, args ...interface{}) *EnumerateOperation
func (*EnumerateOperation) ByRawPrefix ¶
func (t *EnumerateOperation) ByRawPrefix(prefix []byte) *EnumerateOperation
func (*EnumerateOperation) DoProto ¶
func (t *EnumerateOperation) DoProto(factory func() proto.Message, cb func(*ProtoEntry) bool) error
func (*EnumerateOperation) OnlyKeys ¶
func (t *EnumerateOperation) OnlyKeys() *EnumerateOperation
func (*EnumerateOperation) Reverse ¶
func (t *EnumerateOperation) Reverse() *EnumerateOperation
func (*EnumerateOperation) Seek ¶
func (t *EnumerateOperation) Seek(formatSeek string, args ...interface{}) *EnumerateOperation
func (*EnumerateOperation) WithBatchSize ¶
func (t *EnumerateOperation) WithBatchSize(batchSize int) *EnumerateOperation
type GetOperation ¶
type GetOperation struct { DataStore // should be initialized Context context.Context // should be initialized // contains filtered or unexported fields }
func (*GetOperation) ByKey ¶
func (t *GetOperation) ByKey(formatKey string, args ...interface{}) *GetOperation
func (*GetOperation) ByRawKey ¶
func (t *GetOperation) ByRawKey(key []byte) *GetOperation
func (*GetOperation) Required ¶
func (t *GetOperation) Required() *GetOperation
func (*GetOperation) ToBinary ¶
func (t *GetOperation) ToBinary() ([]byte, error)
func (*GetOperation) ToCounter ¶
func (t *GetOperation) ToCounter() (uint64, error)
func (*GetOperation) ToEntry ¶
func (t *GetOperation) ToEntry() (entry RawEntry, err error)
func (*GetOperation) ToProtoEntry ¶
func (t *GetOperation) ToProtoEntry(factory func() proto.Message) (entry ProtoEntry, err error)
func (*GetOperation) ToString ¶
func (t *GetOperation) ToString() (string, error)
type IncrementOperation ¶
type IncrementOperation struct { DataStore // should be initialized Context context.Context // should be initialized Initial int64 Delta int64 // should be initialized by 1 // contains filtered or unexported fields }
func (*IncrementOperation) ByKey ¶
func (t *IncrementOperation) ByKey(formatKey string, args ...interface{}) *IncrementOperation
func (*IncrementOperation) ByRawKey ¶
func (t *IncrementOperation) ByRawKey(key []byte) *IncrementOperation
func (*IncrementOperation) Do ¶
func (t *IncrementOperation) Do() (prev int64, err error)
func (*IncrementOperation) WithDelta ¶
func (t *IncrementOperation) WithDelta(delta int64) *IncrementOperation
func (*IncrementOperation) WithInitialValue ¶
func (t *IncrementOperation) WithInitialValue(initial int64) *IncrementOperation
func (*IncrementOperation) WithTtl ¶
func (t *IncrementOperation) WithTtl(ttlSeconds int) *IncrementOperation
type ManagedDataStore ¶
type ManagedDataStore interface { DataStore DataStoreManager Instance() interface{} }
type ManagedTransactionalDataStore ¶
type ManagedTransactionalDataStore interface { DataStore DataStoreManager TransactionalManager }
type RemoveOperation ¶
type RemoveOperation struct { DataStore // should be initialized Context context.Context // should be initialized // contains filtered or unexported fields }
func (*RemoveOperation) ByKey ¶
func (t *RemoveOperation) ByKey(formatKey string, args ...interface{}) *RemoveOperation
func (*RemoveOperation) ByRawKey ¶
func (t *RemoveOperation) ByRawKey(key []byte) *RemoveOperation
func (*RemoveOperation) Do ¶
func (t *RemoveOperation) Do() error
type SetOperation ¶
type SetOperation struct { DataStore // should be initialized Context context.Context // should be initialized // contains filtered or unexported fields }
func (*SetOperation) Binary ¶
func (t *SetOperation) Binary(value []byte) error
func (*SetOperation) ByKey ¶
func (t *SetOperation) ByKey(formatKey string, args ...interface{}) *SetOperation
func (*SetOperation) ByRawKey ¶
func (t *SetOperation) ByRawKey(key []byte) *SetOperation
func (*SetOperation) Counter ¶
func (t *SetOperation) Counter(value uint64) error
func (*SetOperation) String ¶
func (t *SetOperation) String(value string) error
func (*SetOperation) WithTtl ¶
func (t *SetOperation) WithTtl(ttlSeconds int) *SetOperation
type Transaction ¶
func GetTransaction ¶
func GetTransaction(ctx context.Context, beanName string) (Transaction, bool)
func NewInnerTransaction ¶
func NewInnerTransaction(parent Transaction) Transaction
type TransactionalDataStore ¶
type TransactionalDataStore interface { DataStore TransactionalManager }
Click to show internal directories.
Click to hide internal directories.