Documentation ¶
Index ¶
- Constants
- func Run(users map[string]string, cfg map[string]interface{}) error
- type ConnHandel
- func (h *ConnHandel) DeleteMulti(data []byte) RespMsg
- func (h *ConnHandel) DeleteSingle(data []byte) RespMsg
- func (h *ConnHandel) GetKeys() RespMsg
- func (h *ConnHandel) GetUsers() RespMsg
- func (h *ConnHandel) Login(data []byte) RespMsg
- func (h *ConnHandel) PipeAll(data []byte) RespMsg
- func (h *ConnHandel) PipeLength(data []byte) RespMsg
- func (h *ConnHandel) PipePull(fc byte, data []byte) RespMsg
- func (h *ConnHandel) PipePush(data []byte) RespMsg
- func (h *ConnHandel) ReadMulti(data []byte) RespMsg
- func (h *ConnHandel) ReadSingle(data []byte) RespMsg
- func (h *ConnHandel) SelfIncrease(data []byte, value int64) RespMsg
- func (h *ConnHandel) Write(fc byte, data []byte) RespMsg
- type MemoryKeyValueMap
- func (db *MemoryKeyValueMap) MmAddUser(username, password string) error
- func (db *MemoryKeyValueMap) MmAddUsers(users map[string]string)
- func (db *MemoryKeyValueMap) MmCheckUser(username, password string) (bool, error)
- func (db *MemoryKeyValueMap) MmDeleteMulti(keys []string) int64
- func (db *MemoryKeyValueMap) MmDeleteSingle(key string) int64
- func (db *MemoryKeyValueMap) MmGetUsersDict() []string
- func (db *MemoryKeyValueMap) MmPipeAll(key string) ([]interface{}, error)
- func (db *MemoryKeyValueMap) MmPipeLength(key string) (int, error)
- func (db *MemoryKeyValueMap) MmPipePull(fc byte, key string) (int, interface{}, error)
- func (db *MemoryKeyValueMap) MmPipePush(key string, value interface{}) (int, error)
- func (db *MemoryKeyValueMap) MmReadMulti(keys []string) (datas []RespMsg)
- func (db *MemoryKeyValueMap) MmReadSingle(key string) (val interface{}, ok bool)
- func (db *MemoryKeyValueMap) MmSelfIncrease(key string, value int64) (interface{}, error)
- func (db *MemoryKeyValueMap) MmWriteMulti(maps map[string]interface{}) []RespMsg
- func (db *MemoryKeyValueMap) MmWriteSingle(key string, value interface{}) (interface{}, error)
- type RespMsg
- type UserDict
- type UserMsg
Constants ¶
View Source
const (
VERSION = "v1.0.0" //版本号
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnHandel ¶
type ConnHandel struct { Id int64 //序号 Conn net.Conn //通讯连接 Logged bool //是否已登录标志 TxBytes int64 //发送字节数 RxBytes int64 //接收字节数 TxTimes int64 //发送次数 RxTimes int64 //接收次数 User string //用户信息 Closed bool //连接已关闭 LogAt time.Time //登录时间 CreatedAt time.Time //创建时间 CloseAt time.Time //关闭时间 }
通讯句柄结构
func (*ConnHandel) SelfIncrease ¶
func (h *ConnHandel) SelfIncrease(data []byte, value int64) RespMsg
标签自增
type MemoryKeyValueMap ¶
运行数据库结构
var ( Db MemoryKeyValueMap //内存数据库 ConnPool []*ConnHandel //连接池 )
func (*MemoryKeyValueMap) MmAddUser ¶
func (db *MemoryKeyValueMap) MmAddUser(username, password string) error
添加用户
func (*MemoryKeyValueMap) MmAddUsers ¶
func (db *MemoryKeyValueMap) MmAddUsers(users map[string]string)
添加多个用户
func (*MemoryKeyValueMap) MmCheckUser ¶
func (db *MemoryKeyValueMap) MmCheckUser(username, password string) (bool, error)
校验用户
func (*MemoryKeyValueMap) MmDeleteMulti ¶
func (db *MemoryKeyValueMap) MmDeleteMulti(keys []string) int64
删除多个标签 返回删除成功的标签数
func (*MemoryKeyValueMap) MmDeleteSingle ¶
func (db *MemoryKeyValueMap) MmDeleteSingle(key string) int64
删除单个标签 如果删除成功(标签存在),返回1 如果标签不存在,返回0
func (*MemoryKeyValueMap) MmGetUsersDict ¶
func (db *MemoryKeyValueMap) MmGetUsersDict() []string
读取用户名字典
func (*MemoryKeyValueMap) MmPipeAll ¶
func (db *MemoryKeyValueMap) MmPipeAll(key string) ([]interface{}, error)
获取管道中的所有数据 返回管道剩余长度和错误信息
func (*MemoryKeyValueMap) MmPipeLength ¶
func (db *MemoryKeyValueMap) MmPipeLength(key string) (int, error)
获取管道长度 返回管道剩余长度和错误信息
func (*MemoryKeyValueMap) MmPipePull ¶
func (db *MemoryKeyValueMap) MmPipePull(fc byte, key string) (int, interface{}, error)
从管道拉取数据 返回管道剩余长度、数据、错误信息
func (*MemoryKeyValueMap) MmPipePush ¶
func (db *MemoryKeyValueMap) MmPipePush(key string, value interface{}) (int, error)
压入管道 返回管道长度和错误信息
func (*MemoryKeyValueMap) MmReadMulti ¶
func (db *MemoryKeyValueMap) MmReadMulti(keys []string) (datas []RespMsg)
读取多个标签
func (*MemoryKeyValueMap) MmReadSingle ¶
func (db *MemoryKeyValueMap) MmReadSingle(key string) (val interface{}, ok bool)
读取单个标签
func (*MemoryKeyValueMap) MmSelfIncrease ¶
func (db *MemoryKeyValueMap) MmSelfIncrease(key string, value int64) (interface{}, error)
标签自增
func (*MemoryKeyValueMap) MmWriteMulti ¶
func (db *MemoryKeyValueMap) MmWriteMulti(maps map[string]interface{}) []RespMsg
写多个标签 返回新创建的标签数
func (*MemoryKeyValueMap) MmWriteSingle ¶
func (db *MemoryKeyValueMap) MmWriteSingle(key string, value interface{}) (interface{}, error)
//读取用户键字典
func (db *MemoryKeyValueMap) MmGetKeysDictx() map[string]string { if keysmp, ok := db.Load(_KeysDict); ok { if dict, ok := keysmp.(map[string]time.Time); ok { keys := make(map[string]string) for k, v := range dict { keys[k] = v.Local().Format("2006-01-02T15:04:05.000") } return keys } } db.Store(_KeysDict, make(map[string]time.Time)) return nil }
//添加键到字典中
func (db *MemoryKeyValueMap) addToKeysDict(keys ...string) { if keysmp, ok := db.Load(_KeysDict); ok { if dict, ok := keysmp.(map[string]time.Time); ok { for _, k := range keys { dict[k] = time.Now() } db.Store(_KeysDict, dict) } } else { db.Store(_KeysDict, make(map[string]time.Time)) } }
//从字典中删除键
func (db *MemoryKeyValueMap) deleteFromKeysDict(keys ...string) { if keysmp, ok := db.Load(_KeysDict); ok { if dict, ok := keysmp.(map[string]time.Time); ok { for _, k := range keys { delete(dict, k) } db.Store(_KeysDict, dict) } } else { db.Store(_KeysDict, make(map[string]time.Time)) } }
写单个标签
Click to show internal directories.
Click to hide internal directories.