Documentation ¶
Index ¶
- Variables
- func NewService(e *environment.Environment) (service.Service, error)
- type DMap
- func (dm *DMap) Decr(ctx context.Context, key string, delta int) (int, error)
- func (dm *DMap) Delete(ctx context.Context, keys ...string) (int, error)
- func (dm *DMap) Destroy(ctx context.Context) error
- func (dm *DMap) Expire(ctx context.Context, key string, timeout time.Duration) error
- func (dm *DMap) Get(ctx context.Context, key string) (storage.Entry, error)
- func (dm *DMap) GetPut(ctx context.Context, key string, value interface{}) (storage.Entry, error)
- func (dm *DMap) Incr(ctx context.Context, key string, delta int) (int, error)
- func (dm *DMap) IncrByFloat(ctx context.Context, key string, delta float64) (float64, error)
- func (dm *DMap) Lease(ctx context.Context, key string, token []byte, timeout time.Duration) error
- func (dm *DMap) Lock(ctx context.Context, key string, timeout, deadline time.Duration) ([]byte, error)
- func (dm *DMap) Name() string
- func (dm *DMap) Put(ctx context.Context, key string, value interface{}, cfg *PutConfig) error
- func (dm *DMap) Scan(partID, cursor uint64, sc *ScanConfig) ([]string, uint64, error)
- func (dm *DMap) Unlock(ctx context.Context, key string, token []byte) error
- type Entry
- type PutConfig
- type ScanConfig
- type ScanOption
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // DeleteHits is the number of deletion requests resulting in an item being removed. DeleteHits = stats.NewInt64Counter() // DeleteMisses is the number of deletion requests for missing keys. DeleteMisses = stats.NewInt64Counter() )
var ( // ErrKeyNotFound is returned when a key could not be found. ErrKeyNotFound = errors.New("key not found") ErrDMapNotFound = errors.New("dmap not found") ErrServerGone = errors.New("server is gone") )
var ( // GetMisses is the number of entries that have been requested and not found GetMisses = stats.NewInt64Counter() // GetHits is the number of entries that have been requested and found present GetHits = stats.NewInt64Counter() // EvictedTotal is the number of entries removed from cache to free memory for new entries. EvictedTotal = stats.NewInt64Counter() )
var ( // ErrLockNotAcquired is returned when the requested lock could not be acquired ErrLockNotAcquired = errors.New("lock not acquired") // ErrNoSuchLock is returned when the requested lock does not exist ErrNoSuchLock = errors.New("no such lock") )
var ( ErrKeyFound = errors.New("key found") ErrWriteQuorum = errors.New("write quorum cannot be reached") ErrKeyTooLarge = errors.New("key too large") ErrEntryTooLarge = errors.New("entry too large for the configured table size") )
var EntriesTotal = stats.NewInt64Counter()
EntriesTotal is the total number of entries(including replicas) stored during the life of this instance.
var ErrReadQuorum = errors.New("read quorum cannot be reached")
ErrReadQuorum means that read quorum cannot be reached to operate.
Functions ¶
func NewService ¶
func NewService(e *environment.Environment) (service.Service, error)
Types ¶
type DMap ¶
type DMap struct {
// contains filtered or unexported fields
}
DMap implements a single-hop distributed hash table.
func (*DMap) Decr ¶
Decr atomically decrements key by delta. The return value is the new value after being decremented or an error.
func (*DMap) Delete ¶
Delete deletes the value for the given key. Delete will not return error if key doesn't exist. It's thread-safe. It is safe to modify the contents of the argument after Delete returns.
func (*DMap) Destroy ¶
Destroy flushes the given DMap on the cluster. You should know that there is no global lock on DMaps. So if you call Put, Put with EX and Destroy methods concurrently on the cluster, Put and Put with EX calls may set new values to the DMap.
func (*DMap) Expire ¶
Expire updates the expiry for the given key. It returns ErrKeyNotFound if the DB does not contain the key. It's thread-safe.
func (*DMap) Get ¶
Get gets the value for the given key. It returns ErrKeyNotFound if the DB does not contain the key. It's thread-safe. It is safe to modify the contents of the returned value.
func (*DMap) Incr ¶
Incr atomically increments key by delta. The return value is the new value after being incremented or an error.
func (*DMap) IncrByFloat ¶ added in v0.5.0
IncrByFloat atomically increments key by delta. The return value is the new value after being incremented or an error.
func (*DMap) Lease ¶ added in v0.5.0
Lease takes key and token and tries to update the expiry with duration. It redirects the request to the partition owner, if required.
func (*DMap) Lock ¶
func (dm *DMap) Lock(ctx context.Context, key string, timeout, deadline time.Duration) ([]byte, error)
Lock prepares a token and env, then calls tryLock
func (*DMap) Put ¶
Put sets the value for the given key. It overwrites any previous value for that key, and it's thread-safe. The key has to be a string. value type is arbitrary. It is safe to modify the contents of the arguments after Put returns but not before.
type ScanConfig ¶ added in v0.5.0
type ScanOption ¶ added in v0.5.0
type ScanOption func(*ScanConfig)
func Count ¶ added in v0.5.0
func Count(c int) ScanOption
func Match ¶ added in v0.5.0
func Match(s string) ScanOption
type Service ¶
type Service struct { sync.RWMutex // protects dmaps map // contains filtered or unexported fields }
func (*Service) NewDMap ¶
NewDMap creates and returns a new DMap instance. It checks member count quorum and bootstrapping status before creating a new DMap.
func (*Service) RegisterHandlers ¶ added in v0.5.0
func (s *Service) RegisterHandlers()
Source Files ¶
- atomic.go
- atomic_handlers.go
- balance.go
- compaction.go
- config.go
- delete.go
- delete_handlers.go
- destroy.go
- destroy_handlers.go
- dmap.go
- env.go
- eviction.go
- expire.go
- expire_handlers.go
- fragment.go
- get.go
- get_handlers.go
- handlers.go
- janitor.go
- lock.go
- lock_handlers.go
- put.go
- put_handlers.go
- scan_handlers.go
- service.go