cache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncIterNumCacheSize int64 = 1 * 1024 * 1024
	IncIterNumCacheTTL        = 10 * time.Minute
)
View Source
const TimeSizeBytes = int(unsafe.Sizeof(time.Time{}))

Variables

Functions

func GetGlobalIterNum

func GetGlobalIterNum(queryID string) (int32, bool)

func GetNodeIterNum

func GetNodeIterNum(queryID string) (int32, bool)

func PutGlobalIterNum

func PutGlobalIterNum(queryID string, iterCount int32)

func PutNodeIterNum

func PutNodeIterNum(queryID string, iterCount int32)

func UpdateIterNumFunc

func UpdateIterNumFunc(old, new Entry) bool

func UpdateMetaData

func UpdateMetaData(_, _ Entry) bool

Types

type Cache

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

func NewCache

func NewCache(maxBytes int64, expireTime time.Duration) *Cache

NewCache used to create a cache instance.

func (*Cache) Get

func (c *Cache) Get(key string) (Entry, bool)

Get used to obtain the value of the key and returns whether the key is obtained successfully.

func (*Cache) Len

func (c *Cache) Len() int

Len used to obtain the number of elements in the cache.

func (*Cache) Put

func (c *Cache) Put(key string, value Entry, needUpdate func(old Entry, new Entry) bool)

Put used to add or update a Key-Value Pair

func (*Cache) Remove

func (c *Cache) Remove(key string)

Remove to delete an element with a specified key.

type Entry

type Entry interface {
	SetTime(time time.Time)
	GetTime() time.Time
	SetValue(value interface{})
	GetValue() interface{}
	GetKey() string
	Size() int64
}

type IncIterNumEntry

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

func NewIncIterNumEntry

func NewIncIterNumEntry(queryID string) *IncIterNumEntry

func (*IncIterNumEntry) GetKey

func (e *IncIterNumEntry) GetKey() string

func (*IncIterNumEntry) GetTime

func (e *IncIterNumEntry) GetTime() time.Time

func (*IncIterNumEntry) GetValue

func (e *IncIterNumEntry) GetValue() interface{}

func (*IncIterNumEntry) SetTime

func (e *IncIterNumEntry) SetTime(time time.Time)

func (*IncIterNumEntry) SetValue

func (e *IncIterNumEntry) SetValue(value interface{})

func (*IncIterNumEntry) Size

func (e *IncIterNumEntry) Size() int64

Jump to

Keyboard shortcuts

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