Documentation
¶
Index ¶
- Variables
- type Config
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(key string) (bool, error)
- func (s *Store) DeleteRemote(key string, deletedAt int64) error
- func (s *Store) Get(key string) (any, error)
- func (s *Store) GetAndDelete(key string) (any, error)
- func (s *Store) Len() int
- func (s *Store) RegisterDecoder(keyPrefix string, decoder TypeDecoder)
- func (s *Store) Set(key string, value any) error
- func (s *Store) SetDelegate(d SyncDelegate)
- func (s *Store) SetNXWithTTL(key string, value any, ttl time.Duration) (bool, error)
- func (s *Store) SetRemote(key string, valueJSON []byte, writtenAt int64, expiresAt int64) error
- func (s *Store) SetWithTTL(key string, value any, ttl time.Duration) error
- type SyncDelegate
- type TypeDecoder
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// CleanupInterval controls how often expired entries are removed.
// If <= 0, defaults to 30s.
CleanupInterval time.Duration
// DefaultTTL applies when Set is used.
// A zero value means entries do not expire by default.
DefaultTTL time.Duration
}
Config controls in-memory KV store behavior.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an in-memory KV store with optional TTL support.
func (*Store) DeleteRemote ¶
DeleteRemote applies a remotely-gossiped delete without triggering OnDelete. deletedAt is the absolute Unix nanosecond timestamp when the delete was issued. The delete is skipped if the local entry was written after the delete intent (last-write-wins).
func (*Store) GetAndDelete ¶
GetAndDelete retrieves and deletes a key atomically.
func (*Store) RegisterDecoder ¶
func (s *Store) RegisterDecoder(keyPrefix string, decoder TypeDecoder)
RegisterDecoder registers a decoder for keys matching the given prefix. Used by the receiving side to reconstruct concrete types from gossip payloads.
func (*Store) SetDelegate ¶
func (s *Store) SetDelegate(d SyncDelegate)
SetDelegate plugs in the cluster sync implementation.
func (*Store) SetNXWithTTL ¶
SetNXWithTTL atomically sets a value with TTL only if the key does not exist. Returns true if the key was set, false if the key already existed. ttl=0 means no expiration.
func (*Store) SetRemote ¶
SetRemote applies a remotely-gossiped entry without triggering OnSet. writtenAt and expiresAt must be absolute Unix nanosecond timestamps. If the local entry was written more recently than writtenAt the update is silently skipped (last-write-wins by wall clock on the writing node).
type SyncDelegate ¶
type SyncDelegate interface {
OnSet(key string, valueJSON []byte, writtenAt int64, expiresAt int64)
OnDelete(key string, deletedAt int64)
}
SyncDelegate is notified of all mutations, enabling cross-node replication. All calls happen synchronously after the local mutation has succeeded. writtenAt / deletedAt are absolute Unix nanosecond timestamps used by remote nodes for last-write-wins conflict resolution. expiresAt is an absolute Unix nanosecond timestamp; 0 means no expiration.
type TypeDecoder ¶
TypeDecoder reconstructs a concrete value from its JSON representation. Register decoders by key prefix via RegisterDecoder.