Documentation ¶
Index ¶
- func Args(args interface{}) []interface{}
- func ArgsString(fields []string) []interface{}
- func ArgsStringAhead(key string, fields []string) []interface{}
- func CheckError(err error)
- func Col(arr interface{}, result interface{}, field string)
- func ColInt(arr interface{}, field string) []int
- func ColInt2Str(arr interface{}, field string, fn func(id int) string) []string
- func GetField(v interface{}, field string) interface{}
- func JoinFields(prefix string, fields ...string) string
- func MapIds(ids []int, fn func(id int) string) []string
- func Panic(msg string, err error)
- func PtrValue(v reflect.Value) reflect.Value
- func Unique(ids []int) []int
- type Dao
- type MysqlConfig
- type MysqlService
- type MysqlWrapper
- func (m *MysqlWrapper) CountByKeys(table, appendSql string, kvs ...interface{}) int64
- func (m *MysqlWrapper) Delete(table string, id interface{}) sql.Result
- func (m *MysqlWrapper) DeleteList(list ...interface{}) interface{}
- func (m *MysqlWrapper) Exec(query string, args ...interface{}) sql.Result
- func (m *MysqlWrapper) Get(i interface{}, id interface{})
- func (m *MysqlWrapper) GetByKey(i interface{}, kvs ...interface{})
- func (m *MysqlWrapper) GetObject(i interface{}, id interface{}, table string, fields []string)
- func (m *MysqlWrapper) Gets(i interface{}, ids ...interface{})
- func (m *MysqlWrapper) Insert(list ...interface{})
- func (m *MysqlWrapper) List(i interface{}, ids []int)
- func (m *MysqlWrapper) ListByKeys(r interface{}, appendSql string, kvs ...interface{})
- func (m *MysqlWrapper) ListObject(r interface{}, ids []int, table string, fields []string)
- func (m *MysqlWrapper) Select(i interface{}, query string, args ...interface{})
- func (m *MysqlWrapper) SelectFloat(query string, args ...interface{}) float64
- func (m *MysqlWrapper) SelectInt(query string, args ...interface{}) int
- func (m *MysqlWrapper) SelectInt64(query string, args ...interface{}) int64
- func (m *MysqlWrapper) SelectNullFloat(query string, args ...interface{}) null.Float
- func (m *MysqlWrapper) SelectNullInt(query string, args ...interface{}) null.Int
- func (m *MysqlWrapper) SelectNullStr(query string, args ...interface{}) null.String
- func (m *MysqlWrapper) SelectOne(holder interface{}, query string, args ...interface{})
- func (m *MysqlWrapper) SelectStr(query string, args ...interface{}) string
- func (m *MysqlWrapper) Update(table string, param interface{})
- func (m *MysqlWrapper) UpdateObjects(list ...interface{}) int64
- type RMysqlError
- type RedisService
- func (r *RedisService) AddJsonsId(objs interface{}, keyFn func(id int) string, ttl int64)
- func (r *RedisService) AddJsonsInt(objs interface{}, field string, keyFn func(id int) string, ttl int64)
- func (r *RedisService) AllExist(keys ...string) bool
- func (r *RedisService) Close()
- func (r *RedisService) Delete(key string)
- func (r *RedisService) Discard()
- func (r *RedisService) Exec() (interface{}, error)
- func (r *RedisService) Exists(key string) bool
- func (r *RedisService) Expire(key string, newSecondsLifeTime int64)
- func (r *RedisService) Expires(seconds int64, keys []string)
- func (r *RedisService) Get(key interface{}) RedisValue
- func (r *RedisService) GetBytes(key string) []byte
- func (r *RedisService) GetJson(key string, out interface{}) bool
- func (r *RedisService) GetJsonMap(keys []string, out interface{}) error
- func (r *RedisService) GetJsons(keys []string, out interface{}) error
- func (r *RedisService) GetMap(key string) map[string]interface{}
- func (r *RedisService) HDel(key string, field ...string) error
- func (r *RedisService) HGet(key, field string, result interface{})
- func (r *RedisService) HGetAsMap(key, field string) map[string]interface{}
- func (r *RedisService) HMGet(key string, result interface{}, fields ...string)
- func (r *RedisService) HMGetAll(key string, result interface{})
- func (r *RedisService) HMSet(key string, kvs map[string]interface{}, secondsLifetime int64)
- func (r *RedisService) HSet(key, field string, value interface{}, secondsLifetime int64)
- func (r *RedisService) LGet(key string, index int, value interface{})
- func (r *RedisService) LGetAll(key string, result interface{})
- func (r *RedisService) LLen(key string) int
- func (r *RedisService) LSet(key string, objs interface{}, secondsLifetime int64)
- func (r *RedisService) Multi()
- func (r *RedisService) Now() int64
- func (r *RedisService) PingPong() bool
- func (r *RedisService) Publish(channel string, msg interface{}) (int, error)
- func (r *RedisService) Select(db int)
- func (r *RedisService) Set(key interface{}, value interface{}, seconds int)
- func (r *RedisService) SetJson(key string, value interface{}, secondsLifetime int64) (err error)
- func (r *RedisService) SetJsons(keys []string, values interface{}, ttl int64)
- func (r *RedisService) Subscribe(channel string) (*redis.PubSubConn, error)
- func (r *RedisService) TTL(key string) int64
- func (r *RedisService) Time() (int64, int64)
- func (r *RedisService) Unwatch()
- func (r *RedisService) Watch(keys ...string)
- func (r *RedisService) WithTransaction(fn func(), watchKeys ...string) []interface{}
- type RedisValue
- func (r RedisValue) Bool() bool
- func (r RedisValue) Float64() float64
- func (r RedisValue) Float64s() []float64
- func (r RedisValue) Int() int
- func (r RedisValue) Int64() int64
- func (r RedisValue) Int64s() []int64
- func (r RedisValue) Ints() []int
- func (r RedisValue) String() string
- func (r RedisValue) Strings() []string
- type TimeHash
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArgsString ¶
func ArgsString(fields []string) []interface{}
func ArgsStringAhead ¶
func CheckError ¶
func CheckError(err error)
func JoinFields ¶
Types ¶
type Dao ¶
type Dao struct { Mysql *MysqlService Redis *RedisService TTL int64 }
func NewDao ¶
func NewDao(mysql *MysqlService, redis *RedisService, ttl int64) Dao
type MysqlConfig ¶
type MysqlService ¶
type MysqlService struct { *MysqlWrapper DbMap *gorp.DbMap Transaction *gorp.Transaction Tx *MysqlWrapper TmpMysqlWrapper *MysqlWrapper }
func NewMysqlService ¶
func NewMysqlService(url, prefix string, trace bool) *MysqlService
func NewMysqlServiceWithConfig ¶
func NewMysqlServiceWithConfig(config MysqlConfig) *MysqlService
func (*MysqlService) Add ¶
func (s *MysqlService) Add(i interface{})
func (*MysqlService) AddTable ¶
func (s *MysqlService) AddTable(i interface{})
func (*MysqlService) Begin ¶
func (s *MysqlService) Begin()
Begin transaction , in transation we should use `mysql.Tx.Select`
func (*MysqlService) Close ¶
func (s *MysqlService) Close()
func (*MysqlService) Commit ¶
func (s *MysqlService) Commit() error
func (*MysqlService) Rollback ¶
func (s *MysqlService) Rollback() error
func (*MysqlService) WithTransaction ¶
func (s *MysqlService) WithTransaction(fn func())
type MysqlWrapper ¶
type MysqlWrapper struct {
Executor gorp.SqlExecutor
}
func Wrap ¶
func Wrap(executor gorp.SqlExecutor) *MysqlWrapper
func (*MysqlWrapper) CountByKeys ¶
func (m *MysqlWrapper) CountByKeys(table, appendSql string, kvs ...interface{}) int64
func (*MysqlWrapper) Delete ¶
func (m *MysqlWrapper) Delete(table string, id interface{}) sql.Result
func (*MysqlWrapper) DeleteList ¶
func (m *MysqlWrapper) DeleteList(list ...interface{}) interface{}
func (*MysqlWrapper) Exec ¶
func (m *MysqlWrapper) Exec(query string, args ...interface{}) sql.Result
func (*MysqlWrapper) Get ¶
func (m *MysqlWrapper) Get(i interface{}, id interface{})
func (*MysqlWrapper) GetByKey ¶
func (m *MysqlWrapper) GetByKey(i interface{}, kvs ...interface{})
func (*MysqlWrapper) GetObject ¶
func (m *MysqlWrapper) GetObject(i interface{}, id interface{}, table string, fields []string)
func (*MysqlWrapper) Gets ¶
func (m *MysqlWrapper) Gets(i interface{}, ids ...interface{})
func (*MysqlWrapper) Insert ¶
func (m *MysqlWrapper) Insert(list ...interface{})
func (*MysqlWrapper) List ¶
func (m *MysqlWrapper) List(i interface{}, ids []int)
func (*MysqlWrapper) ListByKeys ¶
func (m *MysqlWrapper) ListByKeys(r interface{}, appendSql string, kvs ...interface{})
GetByKeys eg. var r []UserMajor GetByKeys(&r ,"order by id", "uid",1)
func (*MysqlWrapper) ListObject ¶
func (m *MysqlWrapper) ListObject(r interface{}, ids []int, table string, fields []string)
func (*MysqlWrapper) Select ¶
func (m *MysqlWrapper) Select(i interface{}, query string, args ...interface{})
func (*MysqlWrapper) SelectFloat ¶
func (m *MysqlWrapper) SelectFloat(query string, args ...interface{}) float64
func (*MysqlWrapper) SelectInt ¶
func (m *MysqlWrapper) SelectInt(query string, args ...interface{}) int
func (*MysqlWrapper) SelectInt64 ¶
func (m *MysqlWrapper) SelectInt64(query string, args ...interface{}) int64
func (*MysqlWrapper) SelectNullFloat ¶
func (m *MysqlWrapper) SelectNullFloat(query string, args ...interface{}) null.Float
func (*MysqlWrapper) SelectNullInt ¶
func (m *MysqlWrapper) SelectNullInt(query string, args ...interface{}) null.Int
func (*MysqlWrapper) SelectNullStr ¶
func (m *MysqlWrapper) SelectNullStr(query string, args ...interface{}) null.String
func (*MysqlWrapper) SelectOne ¶
func (m *MysqlWrapper) SelectOne(holder interface{}, query string, args ...interface{})
func (*MysqlWrapper) SelectStr ¶
func (m *MysqlWrapper) SelectStr(query string, args ...interface{}) string
func (*MysqlWrapper) Update ¶
func (m *MysqlWrapper) Update(table string, param interface{})
func (*MysqlWrapper) UpdateObjects ¶
func (m *MysqlWrapper) UpdateObjects(list ...interface{}) int64
type RMysqlError ¶
func (RMysqlError) Error ¶
func (r RMysqlError) Error() string
type RedisService ¶
type RedisService struct { // // Connected is true when the Service has already connected // Connected bool // // Config the redis config for this redis Redis redis.Conn }
Service the Redis service, contains the config and the redis Pool
func NewRedisService ¶
func NewRedisService(redisUrl string) *RedisService
NewRedisServices redisUrl like redis://user:secret@localhost:6379/0?foo=bar&qux=baz
func NewService ¶
func NewService(cli redis.Conn) *RedisService
func (*RedisService) AddJsonsId ¶
func (r *RedisService) AddJsonsId(objs interface{}, keyFn func(id int) string, ttl int64)
func (*RedisService) AddJsonsInt ¶
func (r *RedisService) AddJsonsInt(objs interface{}, field string, keyFn func(id int) string, ttl int64)
func (*RedisService) AllExist ¶
func (r *RedisService) AllExist(keys ...string) bool
func (*RedisService) Close ¶
func (r *RedisService) Close()
func (*RedisService) Delete ¶
func (r *RedisService) Delete(key string)
Delete removes redis entry by specific key
func (*RedisService) Discard ¶
func (r *RedisService) Discard()
func (*RedisService) Exec ¶
func (r *RedisService) Exec() (interface{}, error)
func (*RedisService) Exists ¶
func (r *RedisService) Exists(key string) bool
func (*RedisService) Expire ¶
func (r *RedisService) Expire(key string, newSecondsLifeTime int64)
func (*RedisService) Expires ¶
func (r *RedisService) Expires(seconds int64, keys []string)
func (*RedisService) Get ¶
func (r *RedisService) Get(key interface{}) RedisValue
func (*RedisService) GetBytes ¶
func (r *RedisService) GetBytes(key string) []byte
func (*RedisService) GetJson ¶
func (r *RedisService) GetJson(key string, out interface{}) bool
return (exists , error)
func (*RedisService) GetJsonMap ¶
func (r *RedisService) GetJsonMap(keys []string, out interface{}) error
func (*RedisService) GetJsons ¶
func (r *RedisService) GetJsons(keys []string, out interface{}) error
GetJsons eg.GetJsons({"1","2"} , &[]obj)
func (*RedisService) GetMap ¶
func (r *RedisService) GetMap(key string) map[string]interface{}
func (*RedisService) HGet ¶
func (r *RedisService) HGet(key, field string, result interface{})
func (*RedisService) HGetAsMap ¶
func (r *RedisService) HGetAsMap(key, field string) map[string]interface{}
func (*RedisService) HMGet ¶
func (r *RedisService) HMGet(key string, result interface{}, fields ...string)
func (*RedisService) HMGetAll ¶
func (r *RedisService) HMGetAll(key string, result interface{})
result: *map[string]interface{}
func (*RedisService) HMSet ¶
func (r *RedisService) HMSet(key string, kvs map[string]interface{}, secondsLifetime int64)
func (*RedisService) HSet ¶
func (r *RedisService) HSet(key, field string, value interface{}, secondsLifetime int64)
func (*RedisService) LGet ¶
func (r *RedisService) LGet(key string, index int, value interface{})
func (*RedisService) LGetAll ¶
func (r *RedisService) LGetAll(key string, result interface{})
result : is a list point ,eg result = &a ; a is var a []Obj
func (*RedisService) LLen ¶
func (r *RedisService) LLen(key string) int
func (*RedisService) LSet ¶
func (r *RedisService) LSet(key string, objs interface{}, secondsLifetime int64)
objs : a list , eg. []xxx
func (*RedisService) PingPong ¶
func (r *RedisService) PingPong() bool
PingPong sends a ping and receives a pong, if no pong received then returns false and filled error
func (*RedisService) Publish ¶
func (r *RedisService) Publish(channel string, msg interface{}) (int, error)
func (*RedisService) Select ¶
func (r *RedisService) Select(db int)
func (*RedisService) Set ¶
func (r *RedisService) Set(key interface{}, value interface{}, seconds int)
Get returns value, err by its key returns nil and a filled error if something bad happened.
func (*RedisService) SetJson ¶
func (r *RedisService) SetJson(key string, value interface{}, secondsLifetime int64) (err error)
func (*RedisService) SetJsons ¶
func (r *RedisService) SetJsons(keys []string, values interface{}, ttl int64)
func (*RedisService) Subscribe ¶
func (r *RedisService) Subscribe(channel string) (*redis.PubSubConn, error)
func (*RedisService) TTL ¶
func (r *RedisService) TTL(key string) int64
func (*RedisService) Time ¶
func (r *RedisService) Time() (int64, int64)
func (*RedisService) Unwatch ¶
func (r *RedisService) Unwatch()
func (*RedisService) Watch ¶
func (r *RedisService) Watch(keys ...string)
func (*RedisService) WithTransaction ¶
func (r *RedisService) WithTransaction(fn func(), watchKeys ...string) []interface{}
type RedisValue ¶
type RedisValue struct {
Value interface{}
}
func (RedisValue) Bool ¶
func (r RedisValue) Bool() bool
func (RedisValue) Float64 ¶
func (r RedisValue) Float64() float64
func (RedisValue) Float64s ¶
func (r RedisValue) Float64s() []float64
func (RedisValue) Int ¶
func (r RedisValue) Int() int
func (RedisValue) Int64 ¶
func (r RedisValue) Int64() int64
func (RedisValue) Int64s ¶
func (r RedisValue) Int64s() []int64
func (RedisValue) Ints ¶
func (r RedisValue) Ints() []int
func (RedisValue) String ¶
func (r RedisValue) String() string
func (RedisValue) Strings ¶
func (r RedisValue) Strings() []string
type TimeHash ¶
type TimeHash struct { Key string Ttl int //seconds HeartBeat int //seconds Redis *RedisService MaxNoHeartBeatCount int }
func NewTimeHash ¶
func NewTimeHash(redis *RedisService, key string, ttl, heartBeat, maxNoHeartBeatCount int) TimeHash