API
#github.com/xulang-org/packages/memcached
Xu 0.8.8 API
import: memcached #github.com/xulang-org/packages/memcached
counts: 3 fns, 21 methods, 2 types, 0 consts, 0 ifaces
Memcached client package for Xu. Features Standard Memcached Text Protocol implementation in 100% pure Xu. High-performance socket line & byte buffering. Full command suite: set, add, replace, append, prepend, get, delete, incr, decr, touch, stats, flush_all. Channel-based concurrency-safe connection pooling.
github.com/xulang-org/packages · 0.1.1 · Install and use
open
pub fn open(addr string) Client
Purpose
Memcached client package for Xu. Features Standard Memcached Text Protocol implementation in 100% pure Xu. High-performance socket line & byte buffering. Full command suite: set, add, replace, append, prepend, get, delete, incr, decr, touch, stats, flush_all. Channel-based concurrency-safe connection pooling. Throws on failure.
Parameters
addr string- address (string)
Returns
Client — a value of this type
struct Client
pub struct Client {
pub fd int
pub buf string
pub addr string
}
Purpose
Public struct `Client`.
Parameters
fd int- file descriptor
buf string- buffer
addr string- address
dial
pub fn dial(addr string) Client
Purpose
Dial a connection. Throws on failure.
Parameters
addr string- address (string)
Returns
Client — a value of this type
(&mut Client) read_line
pub fn (c &mut Client) read_line() string
Purpose
Method on `&mut Client`: read line. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
string — result string
(&mut Client) read_bytes
pub fn (c &mut Client) read_bytes(n int) string
Purpose
Method on `&mut Client`: read through delim (inclusive). Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
n int- count, length, or limit (int)
Returns
string — result string
(&mut Client) write_raw
pub fn (c &mut Client) write_raw(data string) int
Purpose
Method on `&mut Client`: write raw. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
data string- data (string)
Returns
int — a value of this type
(&mut Client) close
pub fn (c &mut Client) close() int
Purpose
Method on `&mut Client`: close the resource.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
int — a value of this type
(&mut Client) set
pub fn (c &mut Client) set(key string, val string, flags int, exptime int) bool
Purpose
Call `set` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
val string- value (string)
flags int- flags (int)
exptime int- exptime (int)
Returns
bool — true or false
(&mut Client) add
pub fn (c &mut Client) add(key string, val string, flags int, exptime int) bool
Purpose
Method on `&mut Client`: add. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
val string- value (string)
flags int- flags (int)
exptime int- exptime (int)
Returns
bool — true or false
(&mut Client) replace
pub fn (c &mut Client) replace(key string, val string, flags int, exptime int) bool
Purpose
Method on `&mut Client`: replace a substring, limited by n. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
val string- value (string)
flags int- flags (int)
exptime int- exptime (int)
Returns
bool — true or false
(&mut Client) append
pub fn (c &mut Client) append(key string, val string) bool
Purpose
Call `append` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
val string- value (string)
Returns
bool — true or false
(&mut Client) prepend
pub fn (c &mut Client) prepend(key string, val string) bool
Purpose
Call `prepend` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
val string- value (string)
Returns
bool — true or false
(&mut Client) get
pub fn (c &mut Client) get(key string) string
Purpose
Retrieval Commands Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
Returns
string — result string
(&mut Client) get_multi
pub fn (c &mut Client) get_multi(keys []string) []string
Purpose
Method on `&mut Client`: read multi. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
keys []string- keys ([]string)
Returns
[]string — slice result
(&mut Client) delete
pub fn (c &mut Client) delete(key string) bool
Purpose
Deletion & Arithmetic Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
Returns
bool — true or false
(&mut Client) incr
pub fn (c &mut Client) incr(key string, delta int) int
Purpose
Call `incr` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
delta int- delta (int)
Returns
int — a value of this type
(&mut Client) decr
pub fn (c &mut Client) decr(key string, delta int) int
Purpose
Call `decr` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
delta int- delta (int)
Returns
int — a value of this type
(&mut Client) touch
pub fn (c &mut Client) touch(key string, exptime int) bool
Purpose
Call `touch` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
key string- key (string)
exptime int- exptime (int)
Returns
bool — true or false
(&mut Client) version
pub fn (c &mut Client) version() string
Purpose
Admin & Stats Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
string — result string
(&mut Client) flush_all
pub fn (c &mut Client) flush_all() bool
Purpose
Method on `&mut Client`: flush all. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
bool — true or false
(&mut Client) stats
pub fn (c &mut Client) stats() []string
Purpose
Call `stats` on `&mut Client`. Throws on failure.
Parameters
c &mut Client- receiver &mut Client (exclusive borrow)
Returns
[]string — slice result
struct Pool
pub struct Pool {
pub addr string
pub idle chan int
pub max_idle int
}
Purpose
Public struct `Pool`.
Parameters
addr string- address
idle chan int- field (channel; type chan int)
max_idle int- field (int)
new_pool
pub fn new_pool(addr string, max_idle int) Pool
Purpose
Construct pool.
Parameters
addr string- address (string)
max_idle int- max_idle (int)
Returns
Pool — a value of this type
(&Pool) get
pub fn (p &Pool) get() Client
Purpose
Call `get` on `&Pool`. Throws on failure.
Parameters
p &Pool- receiver &Pool (borrow)
Returns
Client — a value of this type
(&Pool) put
pub fn (p &Pool) put(c Client)
Purpose
Call `put` on `&Pool`.
Parameters
p &Pool- receiver &Pool (borrow)
c Client- byte or character code (Client)
(&Pool) close
Purpose
Method on `&Pool`: close the resource.
Parameters
p &Pool- receiver &Pool (borrow)