dbms

package
Version: v0.0.0-...-79bd89f Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package dbms provides common redis action

Index

Constants

View Source
const (
	SearchPhoneIndex = "index:search:phone"
	SearchMailIndex  = "index:search:mail"
	SearchSamIndex   = "index:search:sam"
)
View Source
const (
	//index
	UserIndex    = "index:user"
	TodoIndex    = "index:todo"
	MissionIndex = "index:mission"
	ProjectIndex = "index:project"
	ChatIndex    = "index:chat"
	DeviceIndex  = "index:device"
)

Variables

View Source
var CachePool *redis.Pool
View Source
var DB *sql.DB
View Source
var Pool *redis.Pool

Functions

func CacheDelete

func CacheDelete(key string)

CacheDelete delete the key from cache db

func CacheGet

func CacheGet(key string) string

CacheGet reads a key from redis cache db

func CacheGetSet

func CacheGetSet(key, newValue string) string

CacheGetSet gets a key from the cache db and sets with a new value

func CacheSet

func CacheSet(key string, value interface{}, px time.Duration)

CacheSet sets value with expire

func CreateChatIndex

func CreateChatIndex(cid int, cPid string)

CreateChatIndex creates 'chat public id==>> chat real id' index

func CreateDeviceIndex

func CreateDeviceIndex(uid int, dt string)

CreateDeviceIndex creates 'user real id==>> user device token' index

func CreateMissionIndex

func CreateMissionIndex(mid int, mPid string)

CreateMissionIndex creates 'mission public id==>> mission real id' index

func CreateProjectIndex

func CreateProjectIndex(pid int, pPid string)

CreateProjectIndex creates 'project public id==>> project real id' index

func CreateSearchIndex

func CreateSearchIndex(uid int, info, searchType string)

CreateSearchIndex creates index from user id, phone/mail/sam id

func CreateTodoIndex

func CreateTodoIndex(tid int, tPid string)

CreateTodoIndex creates 'to-do public id==>> to-do real id' index

func CreateUserIndex

func CreateUserIndex(uid int, uPid string)

CreateUserIndex creates 'user public id==>> user real id' index

func DeleteSamId

func DeleteSamId(sid string)

DeleteSamIdSet deletes a sam id from the set

func Get

func Get(key string) (string, error)

Get reads a key from redis db

func NewDB

func NewDB(user, password, host string, port int, database string) *sql.DB

NewDB return a mysql connection

func NewPool

func NewPool(server, password string, db string) *redis.Pool

NewPool return a redis pool

func ReadChatId

func ReadChatId(cPid string) (cid int)

ReadProjectId gets project real id with public id

func ReadDeviceToken

func ReadDeviceToken(uid int) (dt string)

ReadDeviceToken gets user device token with real id

func ReadIfSamIdExist

func ReadIfSamIdExist(sid string) (exist bool)

ReadIfSamIdExist tests if the given sam id is in redis db set

func ReadMissionId

func ReadMissionId(mPid string) (mid int)

ReadMissionId gets mission real id with public id

func ReadProjectId

func ReadProjectId(pPid string) (pid int)

ReadProjectId gets project real id with public id

func ReadTodoId

func ReadTodoId(tPid string) (tid int)

ReadTodoId gets to-do real id with public id

func ReadUserId

func ReadUserId(uPid string) (uid int)

ReadUserId gets user real id with public id

func ReadUserIdWithIndex

func ReadUserIdWithIndex(info, loginType string) (uid int)

ReadUserIdWithIndex reads user id from redis db with index type

func UpdateSamIdSet

func UpdateSamIdSet(sid string)

UpdateSamIdSet adds a sam id to the set

func VisitRecord

func VisitRecord(uid int)

VisitRecord records user visit times

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL