datastore

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Datastore

Statistics

L1 down 

local cache not found -> 
  no l1 => 
  l1 cache not found -> + noKey
    no l2 =>
    l2 cache not found => + L2NoKey
    l2 cache timeout => + timeout 
    l2 cache error => + timeout + error
    l2 cache found => + L1Copy + hasValue
  l1 cache timeout => + timeout + error
  l1 cache error => + error
  l1 cache found => + hasValue

local cache found ->
  expired -> expired
	no l1 => 
	l1 cache not found -> + noKey
	  no l2 =>
	  l2 cache not found => + L2NoKey
	  l2 cache timeout => + timeout
	  l2 cache error => + timeout + error
	  l2 cache found => + L1Copy + hasValue
	l1 cache timeout => + timeout + error
	l1 cache error => + error
	l1 cache found => + hasValue

  no such value => cacheHit + noKey

  found => cacheHit + hasValue

  collision -> collision
	no l1 => 
	l1 cache not found -> + noKey
	  no l2 =>
	  l2 cache not found => + L2NoKey
	  l2 cache timeout => + timeout
	  l2 cache error => + timeout + error
	  l2 cache found => + L1Copy + hasValue
	l1 cache timeout => + timeout + error
	l1 cache error => + error
	l1 cache found => + hasValue
  

Documentation

Index

Constants

View Source
const (
	// CacheStatusFoundNoSuchKey we cache the status that we did not find a cache; this no-cache value has a shorter expiry
	CacheStatusFoundNoSuchKey = CacheStatus(iota)
	// CacheStatusNotFound no such key status
	CacheStatusNotFound
	// CacheStatusFound entry found status
	CacheStatusFound
)
View Source
const (
	ModeServer = StoreMode(0)
	ModeClient = StoreMode(1)
)

Variables

This section is empty.

Functions

func NewStores

func NewStores(cfg *config.DatastoreList, gmetrics *gmetric.Service) (map[string]*Service, error)

NewStores creates new stores

func NewStoresV2 added in v0.6.0

func NewStoresV2(cfg *config.DatastoreList, gmetrics *gmetric.Service, verbose bool) (map[string]*Service, error)

Types

type CacheStatus

type CacheStatus int

type Entry

type Entry struct {
	Key      string
	Data     EntryData
	Hash     int
	NotFound bool
	Expiry   time.Time
}

Entry represents data entry

func (*Entry) DecodeBinary

func (e *Entry) DecodeBinary(stream *bintly.Reader) error

DecodeBinary decodes data to binary stream

func (*Entry) EncodeBinary

func (e *Entry) EncodeBinary(stream *bintly.Writer) error

EncodeBinary encodes data from binary stream

type EntryData

type EntryData interface{}

EntryData

type Key

type Key struct {
	Namespace string
	Set       string
	Value     interface{}
	*aero.GenerationPolicy
	TimeToLive time.Duration
	L2         *Key
}

Key represents a datastore key

func NewKey

func NewKey(cfg *config.Datastore, key string) *Key

func (*Key) AsString

func (k *Key) AsString() string

func (*Key) Key

func (k *Key) Key() (*aero.Key, error)

func (*Key) WritePolicy

func (k *Key) WritePolicy(generation uint32) *aero.WritePolicy

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service datastore service

func NewWithCache

func NewWithCache(config *config.Datastore, l1Client, l2Client *client.Service, counter *gmetric.Operation, writeCounter *gmetric.Operation) (*Service, error)

NewWithCache creates a cache optionally

func (*Service) Config

func (s *Service) Config() *config.Datastore

func (*Service) Enabled

func (s *Service) Enabled() bool

func (*Service) GetInto

func (s *Service) GetInto(ctx context.Context, key *Key, storable Value) (dictHash int, err error)

GetInto implements Storer.GetInto

func (*Service) Key

func (s *Service) Key(key string) *Key

func (*Service) Mode

func (s *Service) Mode() StoreMode

func (*Service) Put

func (s *Service) Put(ctx context.Context, key *Key, value Value, dictHash int) error

Put implements Storer.Put

func (*Service) SetMode

func (s *Service) SetMode(mode StoreMode)

type StoreMode

type StoreMode int

StoreMode represents service mode. TODO: change implementation and split the code appropriately for handling server and client side.

type Storer

type Storer interface {
	// Put writes the value to a set of backplanes.
	// dictHash is provided to invalidate caches in case the same input should result in a different value; kind of like an etag/version.
	Put(ctx context.Context, key *Key, value Value, dictHash int) error

	// GetInto will attempt to pull a value from backplanes.
	// If a further cache has a value but a closer one does not, this should populate the closer cache.
	// Should return the dictHash (etag/version).
	GetInto(ctx context.Context, key *Key, storable Value) (dictHash int, err error)

	// TODO refactor out implementation Aerospike specific values.
	Key(key string) *Key

	// TODO remove / rethink implementation.
	Mode() StoreMode
	SetMode(mode StoreMode)

	Enabled() bool

	Config() *config.Datastore
}

type Value

type Value interface{}

Value represents a datastore value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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