store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TTLNoExpiry time.Duration = -1 // Key exists and does not expire
	TTLExpired  time.Duration = -2 // Key does not exist or is expired
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchItem

type BatchItem struct {
	Key   string
	Entry *entry.Entry
}

func NewItem

func NewItem(key string, dataType types.DataType, data []byte, expiry time.Duration) BatchItem

type BatchResult

type BatchResult struct {
	Key   string
	Type  types.DataType
	Value []byte
	Error error
}

type CacheStore

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

func NewCacheStore

func NewCacheStore(cfg config.Config) (*CacheStore, error)

func (*CacheStore) Close

func (s *CacheStore) Close() error

func (*CacheStore) DecrUInt16

func (s *CacheStore) DecrUInt16(key string, delta uint16, exp time.Duration) error

func (*CacheStore) DecrUInt32

func (s *CacheStore) DecrUInt32(key string, delta uint32, exp time.Duration) error

func (*CacheStore) DecrUInt64

func (s *CacheStore) DecrUInt64(key string, delta uint64, exp time.Duration) error

func (*CacheStore) Delete

func (s *CacheStore) Delete(key string) error

func (*CacheStore) Exists

func (s *CacheStore) Exists(keys ...string) int

func (*CacheStore) Flush

func (s *CacheStore) Flush()

func (*CacheStore) FullSync

func (s *CacheStore) FullSync()

func (*CacheStore) Get

func (s *CacheStore) Get(key string) (types.DataType, []byte, error)

func (*CacheStore) GetBool

func (s *CacheStore) GetBool(key string) (bool, error)

func (*CacheStore) GetFloat32

func (s *CacheStore) GetFloat32(key string) (float32, error)

func (*CacheStore) GetFloat64

func (s *CacheStore) GetFloat64(key string) (float64, error)

func (*CacheStore) GetInt16

func (s *CacheStore) GetInt16(key string) (int16, error)

func (*CacheStore) GetInt32

func (s *CacheStore) GetInt32(key string) (int32, error)

func (*CacheStore) GetInt64

func (s *CacheStore) GetInt64(key string) (int64, error)

func (*CacheStore) GetJSON

func (s *CacheStore) GetJSON(key string, target interface{}) error

func (*CacheStore) GetNoCopy

func (s *CacheStore) GetNoCopy(key string) (types.DataType, []byte, error)

⚠️ WARNING: GetNoCopy returns a reference to internal cache data.

In contrast to the standard Get() method, which returns a **safe copy**,

GetNoCopy is designed for performance-critical scenarios where copying is avoided. However, modifying the returned value may cause unexpected behavior in concurrent environments.

✅ If you don't explicitly need zero-copy performance,

use Get() to avoid race conditions and data corruption.

func (*CacheStore) GetRaw

func (s *CacheStore) GetRaw(key string) ([]byte, error)

func (*CacheStore) GetRawNoCopy

func (s *CacheStore) GetRawNoCopy(key string) ([]byte, error)

func (*CacheStore) GetString

func (s *CacheStore) GetString(key string) (string, error)

func (*CacheStore) GetTime

func (s *CacheStore) GetTime(key string) (time.Time, error)

func (*CacheStore) GetUInt16

func (s *CacheStore) GetUInt16(key string) (uint16, error)

func (*CacheStore) GetUInt32

func (s *CacheStore) GetUInt32(key string) (uint32, error)

func (*CacheStore) GetUInt64

func (s *CacheStore) GetUInt64(key string) (uint64, error)

func (*CacheStore) IncrFloat32

func (s *CacheStore) IncrFloat32(key string, delta float32, exp time.Duration) error

func (*CacheStore) IncrFloat64

func (s *CacheStore) IncrFloat64(key string, delta float64, exp time.Duration) error

func (*CacheStore) IncrInt16

func (s *CacheStore) IncrInt16(key string, delta int16, exp time.Duration) error

func (*CacheStore) IncrInt32

func (s *CacheStore) IncrInt32(key string, delta int32, exp time.Duration) error

func (*CacheStore) IncrInt64

func (s *CacheStore) IncrInt64(key string, delta int64, exp time.Duration) error

func (*CacheStore) IncrUInt16

func (s *CacheStore) IncrUInt16(key string, delta uint16, exp time.Duration) error

func (*CacheStore) IncrUInt32

func (s *CacheStore) IncrUInt32(key string, delta uint32, exp time.Duration) error

func (*CacheStore) IncrUInt64

func (s *CacheStore) IncrUInt64(key string, delta uint64, exp time.Duration) error

func (*CacheStore) IsClosed

func (s *CacheStore) IsClosed() bool

func (*CacheStore) Keys

func (s *CacheStore) Keys() []string

func (*CacheStore) MDelete

func (s *CacheStore) MDelete(keys ...string) []error

func (*CacheStore) MGet

func (s *CacheStore) MGet(keys ...string) []BatchResult

func (*CacheStore) MSet

func (s *CacheStore) MSet(items ...BatchItem) []error

func (*CacheStore) Set

func (s *CacheStore) Set(key string, dataType types.DataType, value []byte, expiry time.Duration) error

func (*CacheStore) SetBool

func (s *CacheStore) SetBool(key string, value bool, exp time.Duration) error

func (*CacheStore) SetFloat32

func (s *CacheStore) SetFloat32(key string, value float32, exp time.Duration) error

func (*CacheStore) SetFloat64

func (s *CacheStore) SetFloat64(key string, value float64, exp time.Duration) error

func (*CacheStore) SetInt16

func (s *CacheStore) SetInt16(key string, value int16, exp time.Duration) error

func (*CacheStore) SetInt32

func (s *CacheStore) SetInt32(key string, value int32, exp time.Duration) error

func (*CacheStore) SetInt64

func (s *CacheStore) SetInt64(key string, value int64, exp time.Duration) error

func (*CacheStore) SetJSON

func (s *CacheStore) SetJSON(key string, value interface{}, exp time.Duration) error

func (*CacheStore) SetRaw

func (s *CacheStore) SetRaw(key string, value []byte, exp time.Duration) error

func (*CacheStore) SetString

func (s *CacheStore) SetString(key string, value string, exp time.Duration) error

func (*CacheStore) SetTime

func (s *CacheStore) SetTime(key string, value time.Time, exp time.Duration) error

func (*CacheStore) SetUInt16

func (s *CacheStore) SetUInt16(key string, value uint16, exp time.Duration) error

func (*CacheStore) SetUInt32

func (s *CacheStore) SetUInt32(key string, value uint32, exp time.Duration) error

func (*CacheStore) SetUInt64

func (s *CacheStore) SetUInt64(key string, value uint64, exp time.Duration) error

func (*CacheStore) Sync

func (s *CacheStore) Sync()

func (*CacheStore) TTL

func (s *CacheStore) TTL(key string) time.Duration

type DirtyAction

type DirtyAction bool
const (
	DirtySet    DirtyAction = true
	DirtyDelete             = false
)

Jump to

Keyboard shortcuts

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