cache

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(prefix string, defCacheTime int) *Client

func (*Client) Delete

func (cc *Client) Delete(key string)

func (*Client) Get

func (cc *Client) Get(key string) (interface{}, bool)

func (*Client) Set

func (cc *Client) Set(key string, val interface{})

func (*Client) SetWithExpire

func (cc *Client) SetWithExpire(key string, val interface{}, duration time.Duration)

type Config

type Config struct {
	Prefix    string
	MCServer  string
	CacheTime int
	MaxConns  int
	Timeout   time.Duration
}

type MultiClient

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

func NewMultiClient

func NewMultiClient(prefix, mcServer string, defCacheTime int) *MultiClient

NewMultiClient method will return a pointer to MultiClient object

func NewMultiClientV2

func NewMultiClientV2(opts *Config) *MultiClient

NewMultiClientV2 method will return a pointer to MultiClient object

func (*MultiClient) DelFromMemory

func (cc *MultiClient) DelFromMemory(key string)

DelFromMemory method will delete the object from memory

func (*MultiClient) Delete

func (cc *MultiClient) Delete(key string)

Delete method will remove the key from both memory cache and memcache

func (*MultiClient) Get

func (cc *MultiClient) Get(key string) (interface{}, bool)

Get method tires to find the key from memory cache then check memcache

func (*MultiClient) GetIntWithSet

func (cc *MultiClient) GetIntWithSet(key string, resultObj int64) (int64, bool)

GetIntWithSet method tries to get the key from program memory cache and if it fails then tries memcache and if the item is found in memcache then it is set in program memory for faster lookup

func (*MultiClient) GetInternalClient

func (cc *MultiClient) GetInternalClient() *cache.Cache

GetInternalClient method will return the pointer to internal memory cache client

func (*MultiClient) GetSliceOrBytes

func (cc *MultiClient) GetSliceOrBytes(key string) (interface{}, bool)

GetSliceOrBytes method tries to get the key from program memory cache and if it fails then tries memcache and if the item is found in memcache then it is set in program memory for faster lookup

func (*MultiClient) GetWithSet

func (cc *MultiClient) GetWithSet(key string, resultObj interface{}) (interface{}, bool)

GetWithSet method tries to get the key from program memory cache and if it fails then tries memcache and if the item is found in memcache then it is set in program memory for faster lookup

func (*MultiClient) Set

func (cc *MultiClient) Set(key string, val interface{})

Set method will set the object in both memory cache and memcache

func (*MultiClient) SetInMemory

func (cc *MultiClient) SetInMemory(key string, val interface{})

SetInMemory method will set the object in memory cache

func (*MultiClient) SetWithExpire

func (cc *MultiClient) SetWithExpire(key string, val interface{}, secs int)

SetWithExpire method will set the object in both memory cache and memcache

Jump to

Keyboard shortcuts

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