memcache

package
v0.1.140 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdapterClass = "@pgo/Client/Memcache/Adapter"

	CmdCas      = "cas"
	CmdAdd      = "add"
	CmdSet      = "set"
	CmdReplace  = "replace"
	CmdAppend   = "append"
	CmdPrepend  = "prepend"
	CmdGet      = "get"
	CmdGets     = "gets"
	CmdDelete   = "delete"
	CmdIncr     = "incr"
	CmdDecr     = "decr"
	CmdTouch    = "touch"
	CmdStats    = "stats"
	CmdFlushAll = "flush_all"
	CmdVersion  = "version"
)

Variables

This section is empty.

Functions

func New

func New(config map[string]interface{}) (interface{}, error)

Memcache Client component, configuration: components:

memcache:
    prefix: "pgo2_"
    maxIdleConn: 10
    maxIdleTime: "60s"
    netTimeout: "1s"
    probInterval: "0s"
    servers:
        - "127.0.0.1:11211"
        - "127.0.0.1:11212"

Types

type Client

type Client struct {
	Pool
}

func (*Client) Add

func (c *Client) Add(key string, v interface{}, expire ...time.Duration) (bool, error)

func (*Client) Del

func (c *Client) Del(key string) (bool, error)

func (*Client) Exists

func (c *Client) Exists(key string) (bool, error)

func (*Client) Get

func (c *Client) Get(key string) (*value.Value, error)

func (*Client) Incr

func (c *Client) Incr(key string, delta int) (int, error)

func (*Client) MAdd

func (c *Client) MAdd(items map[string]interface{}, expire ...time.Duration) (bool, error)

func (*Client) MDel

func (c *Client) MDel(keys []string) (bool, error)

func (*Client) MGet

func (c *Client) MGet(keys []string) (map[string]*value.Value, error)

func (*Client) MSet

func (c *Client) MSet(items map[string]interface{}, expire ...time.Duration) (bool, error)

func (*Client) MultiRetrieve

func (c *Client) MultiRetrieve(cmd string, keys []string) ([]*Item, error)

func (*Client) MultiStore

func (c *Client) MultiStore(cmd string, items []*Item, expires ...time.Duration) (bool, error)

func (*Client) Retrieve

func (c *Client) Retrieve(cmd, key string) (*Item, error)

func (*Client) Set

func (c *Client) Set(key string, v interface{}, expire ...time.Duration) (bool, error)

func (*Client) Store

func (c *Client) Store(cmd string, item *Item, expires ...time.Duration) (bool, error)

type Conn

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

func (*Conn) CheckActive

func (c *Conn) CheckActive() (bool, error)

func (*Conn) Close

func (c *Conn) Close(force bool)

func (*Conn) Delete

func (c *Conn) Delete(key string) (bool, error)

execute delete command, return true if succeed otherwise false

func (*Conn) ExtendDeadLine

func (c *Conn) ExtendDeadLine(deadLine ...time.Duration) bool

func (*Conn) FlushAll

func (c *Conn) FlushAll() (bool, error)

execute flush_all command

func (*Conn) Increment

func (c *Conn) Increment(key string, delta int) (int, error)

execute increment/decrement command, negative delta for decrement, otherwise for increment, if key not found, treat the data as zero, if the data is not uint64 representation, function panic. if decrease data below 0, new data will be 0.

func (*Conn) Retrieve

func (c *Conn) Retrieve(cmd string, keys ...string) (items []*Item, err error)

execute retrieve command, cmd is get or gets, item retrieved by gets cmd has a unique uint64 value, result expects zero or more items, if some of the keys not exists or expired, then corresponding item do not present in the result

func (*Conn) Stats

func (c *Conn) Stats(args ...string) (map[string]string, error)

execute stats command if args is empty, all statistics will be returned, otherwise specified field will be returned

func (*Conn) Store

func (c *Conn) Store(cmd string, item *Item, expire int) (bool, error)

execute store command, cmd is set, add, replace, append, prepend or cas, expire is expiration time, either unix timestamp or offset in seconds from now, 0 means never expires, negative value means immediately expired return true if succeed, otherwise false

func (*Conn) Touch

func (c *Conn) Touch(key string, expire int) (bool, error)

execute touch command expire is expiration time, either unix timestamp or offset in seconds from now, 0 means never expires, negative value means immediately expired

func (*Conn) Version

func (c *Conn) Version() (string, error)

execute version command

type Item

type Item struct {
	Key   string // the key under which to store data
	Data  []byte // the bytes stored under the key
	Flags uint16 // a uint16 associated with the data
	CasId uint64 // a unique uint64 of an existing item
}

type Pool

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

func (*Pool) AddrNewKeys

func (p *Pool) AddrNewKeys(v interface{}) (map[string][]string, map[string]string, error)

func (*Pool) BuildKey

func (p *Pool) BuildKey(key string) string

func (*Pool) GetAddrByKey

func (p *Pool) GetAddrByKey(key string) string

func (*Pool) GetConnByAddr

func (p *Pool) GetConnByAddr(addr string) (conn *Conn, err error)

func (*Pool) GetConnByKey

func (p *Pool) GetConnByKey(key string) (*Conn, error)

func (*Pool) GetServers

func (p *Pool) GetServers() (servers []string)

func (*Pool) Init

func (p *Pool) Init()

func (*Pool) RunAddrFunc

func (p *Pool) RunAddrFunc(addr string, keys []string, wg *sync.WaitGroup, f func(*Conn, []string)) error

func (*Pool) SetMaxIdleConn

func (p *Pool) SetMaxIdleConn(v int)

func (*Pool) SetMaxIdleTime

func (p *Pool) SetMaxIdleTime(v string) error

func (*Pool) SetNetTimeout

func (p *Pool) SetNetTimeout(v string) error

func (*Pool) SetPrefix

func (p *Pool) SetPrefix(prefix string)

func (*Pool) SetProbeInterval

func (p *Pool) SetProbeInterval(v string) error

func (*Pool) SetServers

func (p *Pool) SetServers(v []interface{})

Jump to

Keyboard shortcuts

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