open
pub fn open(addr string) Client用途
打开。失败时 throw。
参数
addrstring- 地址(string)
返回
Client — 该类型的值
API
#github.com/xulang-org/packages/redis扩展包 `redis #github.com/xulang-org/packages/redis`,由模块 github.com/xulang-org/packages 提供。
github.com/xulang-org/packages · 0.1.1 · 安装与使用
openpub fn open(addr string) Client打开。失败时 throw。
addr stringClient — 该类型的值
open_authpub fn open_auth(addr string, password string) Client打开auth。失败时 throw。
addr stringpassword stringClient — 该类型的值
open_urlpub fn open_url(raw string) Client打开url。失败时 throw。
raw stringClient — 该类型的值
dial_urlpub fn dial_url(raw string) Client拨号url。失败时 throw。
raw stringClient — 该类型的值
struct Clientpub struct Client {
pub fd int
pub buf string
pub addr string
}公开结构体 `Client`。
fd intbuf stringaddr stringdialpub fn dial(addr string) Client发起连接。失败时 throw。
addr stringClient — 该类型的值
(&mut Client) read_linepub fn (c &mut Client) read_line() string`&mut Client` 上的方法:读取line。失败时 throw。
c &mut Clientstring — 结果字符串
(&mut Client) read_bytespub fn (c &mut Client) read_bytes(n int) string`&mut Client` 上的方法:读到 delim(含 delim)。失败时 throw。
c &mut Clientn intstring — 结果字符串
(&mut Client) read_valuepub fn (c &mut Client) read_value() Value`&mut Client` 上的方法:读取值。失败时 throw。
c &mut ClientValue — 该类型的值
(&mut Client) write_rawpub fn (c &mut Client) write_raw(data string) int`&mut Client` 上的方法:写入raw。失败时 throw。
c &mut Clientdata stringint — 该类型的值
(&mut Client) dopub fn (c &mut Client) do(args []string) Value`&mut Client` 上的方法:执行一次。失败时 throw。
c &mut Clientargs []stringValue — 该类型的值
(&mut Client) authpub fn (c &mut Client) auth(password string) string在 `&mut Client` 上调用 `auth`。失败时 throw。
c &mut Clientpassword stringstring — 结果字符串
(&mut Client) select_dbpub fn (c &mut Client) select_db(index int) string`&mut Client` 上的方法:selectdb。失败时 throw。
c &mut Clientindex intstring — 结果字符串
(&mut Client) closepub fn (c &mut Client) close() int`&mut Client` 上的方法:关闭资源。
c &mut Clientint — 该类型的值
(&mut Client) pingpub fn (c &mut Client) ping() string在 `&mut Client` 上调用 `ping`。失败时 throw。
c &mut Clientstring — 结果字符串
(&mut Client) echopub fn (c &mut Client) echo(msg string) string在 `&mut Client` 上调用 `echo`。失败时 throw。
c &mut Clientmsg stringstring — 结果字符串
(&mut Client) getpub fn (c &mut Client) get(key string) string在 `&mut Client` 上调用 `get`。失败时 throw。
c &mut Clientkey stringstring — 结果字符串
(&mut Client) setpub fn (c &mut Client) set(key string, val string) string在 `&mut Client` 上调用 `set`。失败时 throw。
c &mut Clientkey stringval stringstring — 结果字符串
(&mut Client) set_expub fn (c &mut Client) set_ex(key string, seconds int, val string) string`&mut Client` 上的方法:设置 ex。失败时 throw。
c &mut Clientkey stringseconds intval stringstring — 结果字符串
(&mut Client) delpub fn (c &mut Client) del(key string) int在 `&mut Client` 上调用 `del`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) del_manypub fn (c &mut Client) del_many(keys []string) int`&mut Client` 上的方法:delmany。失败时 throw。
c &mut Clientkeys []stringint — 该类型的值
(&mut Client) existspub fn (c &mut Client) exists(key string) bool在 `&mut Client` 上调用 `exists`。失败时 throw。
c &mut Clientkey stringbool — 是否成立
(&mut Client) incrpub fn (c &mut Client) incr(key string) int在 `&mut Client` 上调用 `incr`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) decrpub fn (c &mut Client) decr(key string) int在 `&mut Client` 上调用 `decr`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) incr_bypub fn (c &mut Client) incr_by(key string, delta int) int`&mut Client` 上的方法:incr按。失败时 throw。
c &mut Clientkey stringdelta intint — 该类型的值
(&mut Client) decr_bypub fn (c &mut Client) decr_by(key string, delta int) int`&mut Client` 上的方法:decr按。失败时 throw。
c &mut Clientkey stringdelta intint — 该类型的值
(&mut Client) expirepub fn (c &mut Client) expire(key string, seconds int) bool在 `&mut Client` 上调用 `expire`。失败时 throw。
c &mut Clientkey stringseconds intbool — 是否成立
(&mut Client) ttlpub fn (c &mut Client) ttl(key string) int在 `&mut Client` 上调用 `ttl`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) keyspub fn (c &mut Client) keys(pattern string) []string在 `&mut Client` 上调用 `keys`。失败时 throw。
c &mut Clientpattern string[]string — 切片结果
(&mut Client) hgetpub fn (c &mut Client) hget(key string, field string) string在 `&mut Client` 上调用 `hget`。失败时 throw。
c &mut Clientkey stringfield stringstring — 结果字符串
(&mut Client) hsetpub fn (c &mut Client) hset(key string, field string, val string) int在 `&mut Client` 上调用 `hset`。失败时 throw。
c &mut Clientkey stringfield stringval stringint — 该类型的值
(&mut Client) hdelpub fn (c &mut Client) hdel(key string, field string) int在 `&mut Client` 上调用 `hdel`。失败时 throw。
c &mut Clientkey stringfield stringint — 该类型的值
(&mut Client) hexistspub fn (c &mut Client) hexists(key string, field string) bool在 `&mut Client` 上调用 `hexists`。失败时 throw。
c &mut Clientkey stringfield stringbool — 是否成立
(&mut Client) hgetallpub fn (c &mut Client) hgetall(key string) []string在 `&mut Client` 上调用 `hgetall`。失败时 throw。
c &mut Clientkey string[]string — 切片结果
(&mut Client) hkeyspub fn (c &mut Client) hkeys(key string) []string在 `&mut Client` 上调用 `hkeys`。失败时 throw。
c &mut Clientkey string[]string — 切片结果
(&mut Client) hlenpub fn (c &mut Client) hlen(key string) int在 `&mut Client` 上调用 `hlen`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) lpushpub fn (c &mut Client) lpush(key string, val string) int在 `&mut Client` 上调用 `lpush`。失败时 throw。
c &mut Clientkey stringval stringint — 该类型的值
(&mut Client) rpushpub fn (c &mut Client) rpush(key string, val string) int在 `&mut Client` 上调用 `rpush`。失败时 throw。
c &mut Clientkey stringval stringint — 该类型的值
(&mut Client) lpoppub fn (c &mut Client) lpop(key string) string在 `&mut Client` 上调用 `lpop`。失败时 throw。
c &mut Clientkey stringstring — 结果字符串
(&mut Client) rpoppub fn (c &mut Client) rpop(key string) string在 `&mut Client` 上调用 `rpop`。失败时 throw。
c &mut Clientkey stringstring — 结果字符串
(&mut Client) llenpub fn (c &mut Client) llen(key string) int在 `&mut Client` 上调用 `llen`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) lrangepub fn (c &mut Client) lrange(key string, start int, stop int) []string在 `&mut Client` 上调用 `lrange`。失败时 throw。
c &mut Clientkey stringstart intstop int[]string — 切片结果
(&mut Client) saddpub fn (c &mut Client) sadd(key string, member string) int在 `&mut Client` 上调用 `sadd`。失败时 throw。
c &mut Clientkey stringmember stringint — 该类型的值
(&mut Client) srempub fn (c &mut Client) srem(key string, member string) int在 `&mut Client` 上调用 `srem`。失败时 throw。
c &mut Clientkey stringmember stringint — 该类型的值
(&mut Client) sismemberpub fn (c &mut Client) sismember(key string, member string) bool在 `&mut Client` 上调用 `sismember`。失败时 throw。
c &mut Clientkey stringmember stringbool — 是否成立
(&mut Client) smemberspub fn (c &mut Client) smembers(key string) []string在 `&mut Client` 上调用 `smembers`。失败时 throw。
c &mut Clientkey string[]string — 切片结果
(&mut Client) scardpub fn (c &mut Client) scard(key string) int在 `&mut Client` 上调用 `scard`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
(&mut Client) mgetpub fn (c &mut Client) mget(keys []string) []string在 `&mut Client` 上调用 `mget`。失败时 throw。
c &mut Clientkeys []string[]string — 切片结果
(&mut Client) msetpub fn (c &mut Client) mset(pairs []string) string在 `&mut Client` 上调用 `mset`。失败时 throw。
c &mut Clientpairs []stringstring — 结果字符串
(&mut Client) zaddpub fn (c &mut Client) zadd(key string, score f64, member string) int在 `&mut Client` 上调用 `zadd`。失败时 throw。
c &mut Clientkey stringscore f64member stringint — 该类型的值
(&mut Client) zrangepub fn (c &mut Client) zrange(key string, start int, stop int) []string在 `&mut Client` 上调用 `zrange`。失败时 throw。
c &mut Clientkey stringstart intstop int[]string — 切片结果
(&mut Client) zrevrangepub fn (c &mut Client) zrevrange(key string, start int, stop int) []string在 `&mut Client` 上调用 `zrevrange`。失败时 throw。
c &mut Clientkey stringstart intstop int[]string — 切片结果
(&mut Client) zscorepub fn (c &mut Client) zscore(key string, member string) string在 `&mut Client` 上调用 `zscore`。失败时 throw。
c &mut Clientkey stringmember stringstring — 结果字符串
(&mut Client) zrempub fn (c &mut Client) zrem(key string, member string) int在 `&mut Client` 上调用 `zrem`。失败时 throw。
c &mut Clientkey stringmember stringint — 该类型的值
(&mut Client) zcardpub fn (c &mut Client) zcard(key string) int在 `&mut Client` 上调用 `zcard`。失败时 throw。
c &mut Clientkey stringint — 该类型的值
struct Pipelinepub struct Pipeline {
pub raw string
pub count int
}公开结构体 `Pipeline`。
raw stringcount intnew_pipelinepub fn new_pipeline() Pipeline构造 pipeline。
无
Pipeline — 该类型的值
(&Client) pipelinepub fn (c &Client) pipeline() Pipeline在 `&Client` 上调用 `pipeline`。
c &ClientPipeline — 该类型的值
(&mut Pipeline) lenpub fn (p &mut Pipeline) len() int`&mut Pipeline` 上的方法:返回长度。
p &mut Pipelineint — 该类型的值
(&mut Pipeline) commandpub fn (p &mut Pipeline) command(args []string)`&mut Pipeline` 上的方法:命令。
p &mut Pipelineargs []string(&mut Pipeline) pingpub fn (p &mut Pipeline) ping()在 `&mut Pipeline` 上调用 `ping`。
p &mut Pipeline(&mut Pipeline) getpub fn (p &mut Pipeline) get(key string)在 `&mut Pipeline` 上调用 `get`。
p &mut Pipelinekey string(&mut Pipeline) setpub fn (p &mut Pipeline) set(key string, val string)在 `&mut Pipeline` 上调用 `set`。
p &mut Pipelinekey stringval string(&mut Pipeline) set_expub fn (p &mut Pipeline) set_ex(key string, seconds int, val string)`&mut Pipeline` 上的方法:设置 ex。
p &mut Pipelinekey stringseconds intval string(&mut Pipeline) delpub fn (p &mut Pipeline) del(key string)在 `&mut Pipeline` 上调用 `del`。
p &mut Pipelinekey string(&mut Pipeline) incrpub fn (p &mut Pipeline) incr(key string)在 `&mut Pipeline` 上调用 `incr`。
p &mut Pipelinekey string(&mut Pipeline) decrpub fn (p &mut Pipeline) decr(key string)在 `&mut Pipeline` 上调用 `decr`。
p &mut Pipelinekey string(&mut Pipeline) incr_bypub fn (p &mut Pipeline) incr_by(key string, delta int)`&mut Pipeline` 上的方法:incr按。
p &mut Pipelinekey stringdelta int(&mut Pipeline) decr_bypub fn (p &mut Pipeline) decr_by(key string, delta int)`&mut Pipeline` 上的方法:decr按。
p &mut Pipelinekey stringdelta int(&mut Pipeline) expirepub fn (p &mut Pipeline) expire(key string, seconds int)在 `&mut Pipeline` 上调用 `expire`。
p &mut Pipelinekey stringseconds int(&mut Pipeline) ttlpub fn (p &mut Pipeline) ttl(key string)在 `&mut Pipeline` 上调用 `ttl`。
p &mut Pipelinekey string(&mut Pipeline) hgetpub fn (p &mut Pipeline) hget(key string, field string)在 `&mut Pipeline` 上调用 `hget`。
p &mut Pipelinekey stringfield string(&mut Pipeline) hsetpub fn (p &mut Pipeline) hset(key string, field string, val string)在 `&mut Pipeline` 上调用 `hset`。
p &mut Pipelinekey stringfield stringval string(&mut Pipeline) hdelpub fn (p &mut Pipeline) hdel(key string, field string)在 `&mut Pipeline` 上调用 `hdel`。
p &mut Pipelinekey stringfield string(&mut Pipeline) lpushpub fn (p &mut Pipeline) lpush(key string, val string)在 `&mut Pipeline` 上调用 `lpush`。
p &mut Pipelinekey stringval string(&mut Pipeline) rpushpub fn (p &mut Pipeline) rpush(key string, val string)在 `&mut Pipeline` 上调用 `rpush`。
p &mut Pipelinekey stringval string(&mut Pipeline) lpoppub fn (p &mut Pipeline) lpop(key string)在 `&mut Pipeline` 上调用 `lpop`。
p &mut Pipelinekey string(&mut Pipeline) rpoppub fn (p &mut Pipeline) rpop(key string)在 `&mut Pipeline` 上调用 `rpop`。
p &mut Pipelinekey string(&mut Pipeline) saddpub fn (p &mut Pipeline) sadd(key string, member string)在 `&mut Pipeline` 上调用 `sadd`。
p &mut Pipelinekey stringmember string(&mut Pipeline) srempub fn (p &mut Pipeline) srem(key string, member string)在 `&mut Pipeline` 上调用 `srem`。
p &mut Pipelinekey stringmember string(&mut Pipeline) zaddpub fn (p &mut Pipeline) zadd(key string, score f64, member string)在 `&mut Pipeline` 上调用 `zadd`。
p &mut Pipelinekey stringscore f64member string(&mut Pipeline) zrempub fn (p &mut Pipeline) zrem(key string, member string)在 `&mut Pipeline` 上调用 `zrem`。
p &mut Pipelinekey stringmember string(&mut Pipeline) zscorepub fn (p &mut Pipeline) zscore(key string, member string)在 `&mut Pipeline` 上调用 `zscore`。
p &mut Pipelinekey stringmember string(&mut Pipeline) zrangepub fn (p &mut Pipeline) zrange(key string, start int, stop int)在 `&mut Pipeline` 上调用 `zrange`。
p &mut Pipelinekey stringstart intstop int(&mut Pipeline) mgetpub fn (p &mut Pipeline) mget(keys []string)在 `&mut Pipeline` 上调用 `mget`。
p &mut Pipelinekeys []string(&mut Pipeline) msetpub fn (p &mut Pipeline) mset(pairs []string)在 `&mut Pipeline` 上调用 `mset`。
p &mut Pipelinepairs []string(&mut Client) exec_pipelinepub fn (c &mut Client) exec_pipeline(p &mut Pipeline) []Value`&mut Client` 上的方法:execpipeline。失败时 throw。
c &mut Clientp &mut Pipeline[]Value — 切片结果
(&mut Pipeline) execpub fn (p &mut Pipeline) exec(c &mut Client) []Value在 `&mut Pipeline` 上调用 `exec`。失败时 throw。
p &mut Pipelinec &mut Client[]Value — 切片结果
struct Poolpub struct Pool {
pub addr string
pub auth string
pub db int
pub idle chan int
pub max_idle int
}公开结构体 `Pool`。
addr stringauth stringdb intidle chan intmax_idle intnew_poolpub fn new_pool(addr string, max_idle int) Pool构造 pool。
addr stringmax_idle intPool — 该类型的值
new_pool_authpub fn new_pool_auth(addr string, auth string, max_idle int) Pool构造 pool auth。
addr stringauth stringmax_idle intPool — 该类型的值
new_pool_urlpub fn new_pool_url(raw string, max_idle int) Pool构造 pool url。
raw stringmax_idle intPool — 该类型的值
(&Pool) getpub fn (p &Pool) get() Client在 `&Pool` 上调用 `get`。失败时 throw。
p &PoolClient — 该类型的值
(&Pool) putpub fn (p &Pool) put(c Client)在 `&Pool` 上调用 `put`。
p &Poolc Client(&Pool) closepub fn (p &Pool) close()`&Pool` 上的方法:关闭资源。
p &Poolencode_cmdpub fn encode_cmd(args []string) string编码。
args []stringstring — 结果字符串
find_crlfpub fn find_crlf(s &string) intfindcrlf。
s &stringint — 该类型的值
struct RedisURLpub struct RedisURL {
pub host string
pub port int
pub addr string
pub password string
pub db int
}公开结构体 `RedisURL`。
host stringport intaddr stringpassword stringdb intparse_urlpub fn parse_url(raw string) RedisURL解析为 url。
raw stringRedisURL — 该类型的值
const type_strpub const type_str = 1公开常量 `type_str`。 值为 `1`
无
const type_intpub const type_int = 2公开常量 `type_int`。 值为 `2`
无
const type_arrpub const type_arr = 3公开常量 `type_arr`。 值为 `3`
无
const type_nilpub const type_nil = 4公开常量 `type_nil`。 值为 `4`
无
const type_errpub const type_err = 5公开常量 `type_err`。 值为 `5`
无
const type_boolpub const type_bool = 6公开常量 `type_bool`。 值为 `6`
无
const type_mappub const type_map = 7公开常量 `type_map`。 值为 `7`
无
const type_setpub const type_set = 8公开常量 `type_set`。 值为 `8`
无
const type_pushpub const type_push = 9公开常量 `type_push`。 值为 `9`
无
const type_doublepub const type_double = 10公开常量 `type_double`。 值为 `10`
无
const type_big_numberpub const type_big_number = 11公开常量 `type_big_number`。 值为 `11`
无
const type_verbatimpub const type_verbatim = 12公开常量 `type_verbatim`。 值为 `12`
无
struct Valuepub struct Value {
pub typ int
pub str_val string
pub int_val int
pub arr_val []string
pub is_null bool
pub raw string
}公开结构体 `Value`。
typ intstr_val stringint_val intarr_val []stringis_null boolraw stringnil_valuepub fn nil_value() Valuenil值。
无
Value — 该类型的值
str_valuepub fn str_value(s string) Valuestr值。
s stringValue — 该类型的值
int_valuepub fn int_value(n int) Valueint值。
n intValue — 该类型的值
arr_valuepub fn arr_value(arr []string) Valuearr值。
arr []stringValue — 该类型的值
err_valuepub fn err_value(msg string) Valueerr值。
msg stringValue — 该类型的值
bool_valuepub fn bool_value(b bool) Valuebool值。
b boolValue — 该类型的值
(&Value) is_nilpub fn (v &Value) is_nil() bool`&Value` 上的方法:判断是否 nil。
v &Valuebool — 是否成立
(&Value) is_errpub fn (v &Value) is_err() bool`&Value` 上的方法:判断是否 err。
v &Valuebool — 是否成立
(&Value) as_stringpub fn (v &Value) as_string() string`&Value` 上的方法:as字符串。失败时 throw。
v &Valuestring — 结果字符串
(&Value) as_string_orpub fn (v &Value) as_string_or(def string) string`&Value` 上的方法:as字符串or。失败时 throw。
v &Valuedef stringstring — 结果字符串
(&Value) as_intpub fn (v &Value) as_int() int`&Value` 上的方法:asint。失败时 throw。
v &Valueint — 该类型的值
(&Value) as_boolpub fn (v &Value) as_bool() bool`&Value` 上的方法:asbool。失败时 throw。
v &Valuebool — 是否成立
(&Value) elementspub fn (v &Value) elements() []Value在 `&Value` 上调用 `elements`。失败时 throw。
v &Value[]Value — 切片结果
(&Value) as_stringspub fn (v &Value) as_strings() []string`&Value` 上的方法:asstring 切片。失败时 throw。
v &Value[]string — 切片结果