Documentation
¶
Index ¶
- Constants
- Variables
- func Bytes2str(b []byte) string
- func CopyFile(srcName, dstName string) (written int64, err error)
- func Crc32_check(s []byte) []byte
- func DEBUG(v ...interface{})
- func Destroy()
- func DogzipCompress(src []byte) []byte
- func DogzipUnCompress(compressSrc []byte) []byte
- func Hdel(name string, path string)
- func Hdel_all(path string)
- func Hset(name string, value interface{}, path string, expire ...int64) bool
- func LINDEX(key string, index int) (result string, ok bool)
- func LLEN(key string) int
- func LPOP(key string, timeout ...int) (result string, ok bool)
- func LPUSH(key string, list ...string) bool
- func LRANGE(key string, start int, param ...int) ([]string, bool)
- func LREM(key string, count int, value string) bool
- func LTRIM(key string, start int, param ...int) bool
- func Log(format string, v ...interface{})
- func PathExists(path string) (bool, error)
- func RPOP(key string, timeout ...int) (result string, ok bool)
- func RPUSH(key string, list ...string) bool
- func RangePath(path string, f func(string, *Hashvalue) bool)
- func Start(workdir string)
- func StartWebServer(ipPort string)
- type Gzip_writer
- type Hash_file
- type Hashvalue
- func (this *Hashvalue) Delete(key string)
- func (this *Hashvalue) Expire(expire int64)
- func (this *Hashvalue) ExpireAt(timestamp int64)
- func (this *Hashvalue) Get(key string, value interface{}) bool
- func (this *Hashvalue) GetExpire() int64
- func (this *Hashvalue) Hdel()
- func (this *Hashvalue) Hset(value interface{}) bool
- func (this *Hashvalue) INCRBY(key string, add int64) int64
- func (this *Hashvalue) Len() (length int)
- func (this *Hashvalue) Load(key string) (interface{}, bool)
- func (this *Hashvalue) Load_bool(key string) bool
- func (this *Hashvalue) Load_float32(key string) float32
- func (this *Hashvalue) Load_float64(key string) float64
- func (this *Hashvalue) Load_int(key string) int
- func (this *Hashvalue) Load_int16(key string) int16
- func (this *Hashvalue) Load_int32(key string) int32
- func (this *Hashvalue) Load_int64(key string) int64
- func (this *Hashvalue) Load_int8(key string) int8
- func (this *Hashvalue) Load_str(key string) string
- func (this *Hashvalue) Load_uint64(key string) uint64
- func (this *Hashvalue) Range(f func(string, interface{}) bool)
- func (this *Hashvalue) Save()
- func (this *Hashvalue) Save_r()
- func (this *Hashvalue) Set(key string, value interface{}) bool
- func (this *Hashvalue) Store(key string, value interface{})
- type MsgBuffer
- func (w *MsgBuffer) Bytes() []byte
- func (r *MsgBuffer) Close() error
- func (w *MsgBuffer) Len() int
- func (w *MsgBuffer) Make(l int) []byte
- func (w *MsgBuffer) Next(l int) []byte
- func (w *MsgBuffer) PreBytes(n int) []byte
- func (r *MsgBuffer) Read(p []byte) (n int, err error)
- func (r *MsgBuffer) ReadByte() (b byte, err error)
- func (w *MsgBuffer) Reset()
- func (w *MsgBuffer) ResetBuf(b []byte)
- func (r *MsgBuffer) Shift(len int)
- func (w *MsgBuffer) String() string
- func (w *MsgBuffer) Truncate(i int)
- func (w *MsgBuffer) Write(b []byte) (int, error)
- func (w *MsgBuffer) WriteByte(s byte)
- func (w *MsgBuffer) WriteString(s string)
Constants ¶
View Source
const ( CACHE_FILE_NAME = "db.cache" //持久化储存的文件名 SAVE_TIME = 1 //持久化间隔时间,单位秒 GZIP_LIMIT = 4096 //大于这个尺寸就压缩 MAXLEN = 1073741824 //128M 缓存单条消息大于这个尺寸就抛弃 GZIP_LEVEL = 6 //压缩等级 )
本cache包会监听ctrl+c事件以保证缓存被正确保存
Variables ¶
View Source
var ( CACHE_Path = "./cache" ISDEBUG = true //是否fmt打印错误 NoPersistence = false //true则对所有缓存不持久化写入 )
Functions ¶
func LPOP ¶
*
*取出指定列表的第一个元素,如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 *LPOP(list1,100)取出名字为list1的列表,没有会等待100秒 *LPOP(list1)取出列表,没有直接返回 *当ok返回值为false,则为超时取队列失败
func LRANGE ¶
*
- 获取列表指定范围内的元素,起始元素是0
- 表不存在返回false
- LRANGE("list",2,3)取第2到3个元素
- LRANGE("list",5,2)如果start比stop小,调换他们的顺序,取第2到第5个元素
- LRANGE("list",-2,1)取第1个到倒数第2个元素,假如10个元素,等同于1,8
- LRANGE("list",2)如果stop为空,则取第0到2个元素
- LRANGE("list",-3) 取最后3个元素
- 假如stop超过列表长度,返回空 *
func LREM ¶
*
*根据参数 COUNT 的值,移除列表中与参数 VALUE 相等的元素。 *count > 0 : 从表头开始向表尾搜索,移除与 VALUE 相等的元素,数量为 COUNT 。 *count < 0 : 从表尾开始向表头搜索,移除与 VALUE 相等的元素,数量为 COUNT 的绝对值。 *count = 0 : 移除表中所有与 VALUE 相等的值。
func LTRIM ¶
*
- LTRIM 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。
- start 与 stop定义参照LRANGE
- 设置超过最大值的start会清空列表
- 设置超过最大值的stop等同于最大值 *
func RPOP ¶
*
*取出指定列表的最后一个元素,如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。 *RPOP(list1,100)取出名字为list1的列表,没有会等待100秒 *RPOP(list1)取出列表,没有直接返回 *当ok返回值为false,则为超时失败
func RPUSH ¶
* *将一个或多个值插入到列表的尾部(最右边)。 *插入一个值Rpush("mylist","hello") *插入多个值Rpush("mylist","1","2","3") *插入[]interface{}切片:
var list []interface{} list = append(list,"1") list = append(list,map[string]string{"name":"luyu"}) list = append(list,100) Rpush("mylist",list...)
*
func StartWebServer ¶ added in v1.1.0
func StartWebServer(ipPort string)
Types ¶
type Gzip_writer ¶
type Hashvalue ¶
type Hashvalue struct {
// contains filtered or unexported fields
}
func (*Hashvalue) Load ¶
path层
type cache_path struct { cache *sync.Map //hot_step int64 //hot_max int64 //hot_num_max int64 }
func (*Hashvalue) Load_float32 ¶
load返回float32
func (*Hashvalue) Load_float64 ¶
load返回float64
Click to show internal directories.
Click to hide internal directories.