db

package
v0.0.0-...-96491ad Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package db is a generated protocol buffer package.

It is generated from these files:

token.proto

It has these top-level messages:

DB_TOKEN

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthToken = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowToken   = fmt.Errorf("proto: integer overflow")
)

Functions

func GetKeyAllocServer

func GetKeyAllocServer(nodeType uint32, account string) string

GetKeyAllocServer : 账号对应的服务器资源的 KEY

Types

type Account

type Account struct {
	Key string
	// contains filtered or unexported fields
}

Account : 代表 1 个 redis 对象

func NewAccount

func NewAccount(dbName string, key string) *Account

NewAccount : NewAccount 的构造函数

func (*Account) Delete

func (objAccount *Account) Delete() error

Delete : 从 redis 删除数据

func (*Account) DirtyData

func (objAccount *Account) DirtyData() (map[string]interface{}, error)

DirtyData : 获取该对象目前已脏的数据

func (*Account) Expire

func (objAccount *Account) Expire(v uint)

Expire : 向 redis 设置该对象过期时间

func (*Account) GetPasswd

func (objAccount *Account) GetPasswd() string

GetPasswd : 获取字段值

func (*Account) HasKey

func (objAccount *Account) HasKey() (int, error)

HasKey : 是否存在 KEY

返回值,若访问数据库失败返回-1;若 key 存在返回 1 ,否则返回 0 。

func (*Account) IsLoad

func (objAccount *Account) IsLoad() bool

IsLoad : 是否已经从 redis 导入数据

func (*Account) Load

func (objAccount *Account) Load() error

Load : 从 redis 加载数据

func (*Account) Save

func (objAccount *Account) Save() error

Save : 保存数据到 redis

func (*Account) Save2

func (objAccount *Account) Save2(dirtyData map[string]interface{}) error

Save2 : 保存数据到 redis 的第 2 种方法

func (*Account) SetPasswd

func (objAccount *Account) SetPasswd(value string)

SetPasswd : 设置字段值

type AccountServer

type AccountServer struct {
	ServerID *protocol.SERVER_ID
	Address  string
	Port     int32
	Type     config.NodeType
}

AccountServer : 分配的服务资源信息(单个)

func (*AccountServer) Marshal

func (accountserver *AccountServer) Marshal() (string, error)

Marshal : 序列化

func (*AccountServer) Unmarshal

func (accountserver *AccountServer) Unmarshal(data string) error

Unmarshal : 反序列化

type DB_TOKEN

type DB_TOKEN struct {
	Token        string                         `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"`
	AllocServers map[uint32]*protocol.SERVER_ID `` /* 152-byte string literal not displayed */
}

func (*DB_TOKEN) Descriptor

func (*DB_TOKEN) Descriptor() ([]byte, []int)

func (*DB_TOKEN) GetAllocServers

func (m *DB_TOKEN) GetAllocServers() map[uint32]*protocol.SERVER_ID

func (*DB_TOKEN) GetToken

func (m *DB_TOKEN) GetToken() string

func (*DB_TOKEN) Marshal

func (m *DB_TOKEN) Marshal() (dAtA []byte, err error)

func (*DB_TOKEN) MarshalTo

func (m *DB_TOKEN) MarshalTo(dAtA []byte) (int, error)

func (*DB_TOKEN) ProtoMessage

func (*DB_TOKEN) ProtoMessage()

func (*DB_TOKEN) Reset

func (m *DB_TOKEN) Reset()

func (*DB_TOKEN) Size

func (m *DB_TOKEN) Size() (n int)

func (*DB_TOKEN) String

func (m *DB_TOKEN) String() string

func (*DB_TOKEN) Unmarshal

func (m *DB_TOKEN) Unmarshal(dAtA []byte) error

type MgrServer

type MgrServer struct {
	Key uint32
	// contains filtered or unexported fields
}

MgrServer : 代表 1 个 redis 对象

func NewMgrServer

func NewMgrServer(dbName string, key uint32) *MgrServer

NewMgrServer : NewMgrServer 的构造函数

func (*MgrServer) Delete

func (objMgrServer *MgrServer) Delete() error

Delete : 从 redis 删除数据

func (*MgrServer) DirtyData

func (objMgrServer *MgrServer) DirtyData() (map[string]interface{}, error)

DirtyData : 获取该对象目前已脏的数据

func (*MgrServer) Expire

func (objMgrServer *MgrServer) Expire(v uint)

Expire : 向 redis 设置该对象过期时间

func (*MgrServer) GetAddr

func (objMgrServer *MgrServer) GetAddr() string

GetAddr : 获取字段值

func (*MgrServer) GetPort

func (objMgrServer *MgrServer) GetPort() int32

GetPort : 获取字段值

func (*MgrServer) HasKey

func (objMgrServer *MgrServer) HasKey() (int, error)

HasKey : 是否存在 KEY

返回值,若访问数据库失败返回-1;若 key 存在返回 1 ,否则返回 0 。

func (*MgrServer) IsLoad

func (objMgrServer *MgrServer) IsLoad() bool

IsLoad : 是否已经从 redis 导入数据

func (*MgrServer) Load

func (objMgrServer *MgrServer) Load() error

Load : 从 redis 加载数据

func (*MgrServer) Save

func (objMgrServer *MgrServer) Save() error

Save : 保存数据到 redis

func (*MgrServer) Save2

func (objMgrServer *MgrServer) Save2(dirtyData map[string]interface{}) error

Save2 : 保存数据到 redis 的第 2 种方法

func (*MgrServer) SetAddr

func (objMgrServer *MgrServer) SetAddr(value string)

SetAddr : 设置字段值

func (*MgrServer) SetPort

func (objMgrServer *MgrServer) SetPort(value int32)

SetPort : 设置字段值

type RedisAtomic

type RedisAtomic struct {
	Cli redis.Conn
}

RedisAtomic : 自定义 Redis 原子操作

func (*RedisAtomic) DelX

func (redisatomic *RedisAtomic) DelX(key, value string) (int, error)

DelX : 原子操作,封装 `条件删除, if value = "xxx" then del key`

返回值, 1 有删除操作; 0 不需要删除

func (*RedisAtomic) SetGetX

func (redisatomic *RedisAtomic) SetGetX(key, value string, expire int) (string, error)

SetGetX : 原子操作,封装 `不管 SetGetX 有没有设置成功,都重置过期时间为 n`

返回值, 空 表示设置成功; 非空 表示设置失败,并返回原先已设置的值

type RoleName

type RoleName struct {
	Key string
	// contains filtered or unexported fields
}

RoleName : 代表 1 个 redis 对象

func NewRoleName

func NewRoleName(dbName string, key string) *RoleName

NewRoleName : NewRoleName 的构造函数

func (*RoleName) Delete

func (objRoleName *RoleName) Delete() error

Delete : 从 redis 删除数据

func (*RoleName) DirtyData

func (objRoleName *RoleName) DirtyData() (map[string]interface{}, error)

DirtyData : 获取该对象目前已脏的数据

func (*RoleName) Expire

func (objRoleName *RoleName) Expire(v uint)

Expire : 向 redis 设置该对象过期时间

func (*RoleName) GetAccount

func (objRoleName *RoleName) GetAccount() string

GetAccount : 获取字段值

func (*RoleName) HasKey

func (objRoleName *RoleName) HasKey() (int, error)

HasKey : 是否存在 KEY

返回值,若访问数据库失败返回-1;若 key 存在返回 1 ,否则返回 0 。

func (*RoleName) IsLoad

func (objRoleName *RoleName) IsLoad() bool

IsLoad : 是否已经从 redis 导入数据

func (*RoleName) Load

func (objRoleName *RoleName) Load() error

Load : 从 redis 加载数据

func (*RoleName) Save

func (objRoleName *RoleName) Save() error

Save : 保存数据到 redis

func (*RoleName) Save2

func (objRoleName *RoleName) Save2(dirtyData map[string]interface{}) error

Save2 : 保存数据到 redis 的第 2 种方法

func (*RoleName) SetAccount

func (objRoleName *RoleName) SetAccount(value string)

SetAccount : 设置字段值

type Token

type Token struct {
	Key string
	// contains filtered or unexported fields
}

Token : 代表 1 个 redis 对象

func NewToken

func NewToken(dbName string, key string) *Token

NewToken : NewToken 的构造函数

func (*Token) Delete

func (objToken *Token) Delete() error

Delete : 从 redis 删除数据

func (*Token) DirtyData

func (objToken *Token) DirtyData() (map[string]interface{}, error)

DirtyData : 获取该对象目前已脏的数据

func (*Token) Expire

func (objToken *Token) Expire(v uint)

Expire : 向 redis 设置该对象过期时间

func (*Token) GetToken

func (objToken *Token) GetToken(mutable bool) *DB_TOKEN

GetToken : 获取字段值

func (*Token) HasKey

func (objToken *Token) HasKey() (int, error)

HasKey : 是否存在 KEY

返回值,若访问数据库失败返回-1;若 key 存在返回 1 ,否则返回 0 。

func (*Token) IsLoad

func (objToken *Token) IsLoad() bool

IsLoad : 是否已经从 redis 导入数据

func (*Token) Load

func (objToken *Token) Load() error

Load : 从 redis 加载数据

func (*Token) Save

func (objToken *Token) Save() error

Save : 保存数据到 redis

func (*Token) Save2

func (objToken *Token) Save2(dirtyData map[string]interface{}) error

Save2 : 保存数据到 redis 的第 2 种方法

Jump to

Keyboard shortcuts

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