local

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: BSD-2-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Byte Size = 1
	KB        = 1024 * Byte
	MB        = 1024 * KB
	GB        = 1024 * MB
	TB        = 1024 * GB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FreeCache

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

func NewFreeCache

func NewFreeCache(size Size, ttl time.Duration, innerKeyPrefix ...string) *FreeCache

NewFreeCache Create a new cache instance, but the internal cache instances are shared, and they will only be initialized once.

func (*FreeCache) Del

func (c *FreeCache) Del(key string)

func (*FreeCache) Get

func (c *FreeCache) Get(key string) ([]byte, bool)

func (*FreeCache) Key

func (c *FreeCache) Key(key string) string

func (*FreeCache) Set

func (c *FreeCache) Set(key string, b []byte)

func (*FreeCache) UseRandomizedTTL

func (c *FreeCache) UseRandomizedTTL(offset time.Duration)

type Local

type Local interface {
	// Set stores the given data with the specified key.
	Set(key string, data []byte)

	// Get retrieves the data associated with the specified key.
	// It returns the data and a boolean indicating whether the key was found.
	Get(key string) ([]byte, bool)

	// Del deletes the data associated with the specified key.
	Del(key string)
}

type Option

type Option func(o *FreeCache)

Option defines the method to customize an Options.

type Size

type Size int64

type TinyLFU

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

func NewTinyLFU

func NewTinyLFU(size int, ttl time.Duration) *TinyLFU

func (*TinyLFU) Del

func (c *TinyLFU) Del(key string)

func (*TinyLFU) Get

func (c *TinyLFU) Get(key string) ([]byte, bool)

func (*TinyLFU) Set

func (c *TinyLFU) Set(key string, b []byte)

func (*TinyLFU) UseRandomizedTTL

func (c *TinyLFU) UseRandomizedTTL(offset time.Duration)

Jump to

Keyboard shortcuts

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