cache

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CCache

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

func (*CCache) Delete

func (c *CCache) Delete(key string) bool

func (*CCache) Get

func (c *CCache) Get(key string) interface{}

func (*CCache) GetInt

func (c *CCache) GetInt(key string) int

func (*CCache) GetInt64

func (c *CCache) GetInt64(key string) int64

func (*CCache) GetString

func (c *CCache) GetString(key string) string

func (*CCache) IsEnabled

func (c *CCache) IsEnabled() bool

func (*CCache) Set

func (c *CCache) Set(key string, val interface{})

func (*CCache) SetInt

func (c *CCache) SetInt(key string, val int)

func (*CCache) SetInt64

func (c *CCache) SetInt64(key string, val int64)

func (*CCache) SetString

func (c *CCache) SetString(key string, val string)

type CInterface

type CInterface interface {
	IsEnabled() bool
	Delete(key string) bool

	Get(key string) interface{}
	Set(key string, val interface{})

	GetString(key string) string
	SetString(key string, val string)

	GetInt(key string) int
	SetInt(key string, val int)

	GetInt64(key string) int64
	SetInt64(key string, val int64)
}

CInterface contains functions a cache instance need to provide

func NewUmanagedCache

func NewUmanagedCache(ctx context.Context, sizeLimit int64, ttl time.Duration) CInterface

should only be used for testing purpose

type Manager

type Manager interface {
	// Get a cache by name, if a cache already exists with the same name, it will be returned as is without checking maxSize, ttl and enabled matches
	GetCache(ctx context.Context, namespace, name string, maxSize int64, ttl time.Duration, enabled bool) (CInterface, error)
	ListCacheNames(namespace string) []string
	ResetCaches(namespace string)
	IsEnabled() bool
}

Manager contains functions to manage cache instances. It provides functions for creating new cache instances and list all of the names of existing cache instances Each cache instance has unique name and its own cache size and TTL configuration.

func NewCacheManager

func NewCacheManager(ctx context.Context, enabled bool) Manager

Jump to

Keyboard shortcuts

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