Documentation ¶
Overview ¶
This package provides a simple LRU cache. It is based on the LRU implementation in groupcache: https://github.com/golang/groupcache/tree/master/lru
Index ¶
- type Cache
- func (m *Cache) CreateKey(key string) string
- func (m *Cache) Decr(key string) (result int64, err error)
- func (m *Cache) Del(key string) (result bool, err error)
- func (m *Cache) Exists(key string) (result bool, err error)
- func (m *Cache) Get(key string) (result string, err error)
- func (m *Cache) GetBackend() (result *redis.Client, err error)
- func (m *Cache) Incr(key string) (result int64, err error)
- func (m *Cache) Md5(str string) string
- func (m *Cache) Set(key string, value string) (result string, err error)
- func (m *Cache) SetEx(key string, value string, ttl time.Duration) (result string, err error)
- type CacheConfig
- type CacheKeyType
- type Captcha
- type Channel
- type DataBase
- type DrawCenter
- func (m *DrawCenter) Draw(actionId string, playerId string) (result model_draw.Result, err error)
- func (m *DrawCenter) GetAction(actionId string) (result model_draw.Action, err error)
- func (m *DrawCenter) GetActionGifts(actionId string) (result []model_draw.Gift, err error)
- func (m *DrawCenter) GetActionWinners(actionId string) (result []model_draw.Player, err error)
- func (m *DrawCenter) GetGift(actionId string, giftId string) (result model_draw.Gift, err error)
- func (m *DrawCenter) GetPlayer(actionId string, playerId string) (result model_draw.Player, err error)
- func (m *DrawCenter) GetPlayerGifts(actionId string, playerId string) (result []model_draw.Gift, err error)
- func (m *DrawCenter) Verify(actionId string, playerId string, giftId string, verify bool) (result model_draw.VerifyResult, err error)
- type JWTService
- func (m *JWTService) CreateToken(ctx iris.Context, claims interface{}) (token string, err error)
- func (m *JWTService) FromCookie(ctx iris.Context) string
- func (m *JWTService) GetClaims(ctx iris.Context) (claims interface{})
- func (m *JWTService) GetMiddleware() iris.Handler
- func (m *JWTService) RemoveToken(ctx iris.Context)
- func (m *JWTService) VerifyToken(ctx iris.Context) (result *jwt.VerifiedToken, err error)
- type LruCache
- func (c *LruCache) Add(key, value interface{}) bool
- func (c *LruCache) AddEx(key, value interface{}, expire time.Duration) bool
- func (c *LruCache) Contains(key interface{}) bool
- func (c *LruCache) ContainsOrAdd(key, value interface{}) (ok, evict bool)
- func (c *LruCache) Get(key interface{}) (interface{}, bool)
- func (c *LruCache) Keys() []interface{}
- func (c *LruCache) Len() int
- func (c *LruCache) Peek(key interface{}) (interface{}, bool)
- func (c *LruCache) Purge()
- func (c *LruCache) Remove(key interface{})
- func (c *LruCache) RemoveOldest()
- type MsgCenter
- func (m *MsgCenter) CloseChannel(channelIds []string) (err error)
- func (m *MsgCenter) CreateAppChannelId(channelId string) (result string, err error)
- func (m *MsgCenter) OpenChannel(channelIds []string, onReceiveMsg func(*types.MsgContent)) (err error)
- func (m *MsgCenter) SendMsg(channelId, msgType, msg string) (err error)
- type RedisStore
- type SessionCache
- func (m *SessionCache) Del(ctx iris.Context, key string) (result bool, err error)
- func (m *SessionCache) Exists(ctx iris.Context, key string) (result bool, err error)
- func (m *SessionCache) Get(ctx iris.Context, key string) (result string, err error)
- func (m *SessionCache) GetCacheKey(ctx iris.Context, key string) string
- func (m *SessionCache) Incr(ctx iris.Context, key string) (result int64, err error)
- func (m *SessionCache) Md5(str string) string
- func (m *SessionCache) Set(ctx iris.Context, key string, value string, ttl time.Duration) (result string, err error)
- type TaskCenter
- type WxAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCacheByConfig ¶
func NewCacheByConfig(config CacheConfig) *Cache
type CacheConfig ¶
type CacheKeyType ¶
type CacheKeyType int32
const ( ACTION_KEY CacheKeyType = 1 // 活动Key ACTION_WINNER_LIST_KEY CacheKeyType = 2 // 活动中奖者列表Key ACTION_PLAYER_KEY CacheKeyType = 3 // 活动用户Key ACTION_PLAYER_GIFT_LIST_KEY CacheKeyType = 4 // 活动用户获得的奖品列表Key ACTION_GIFT_LIST_KEY CacheKeyType = 5 // 活动奖品列表Key ACTION_GIFT_KEY CacheKeyType = 6 // 活动奖品Key )
type Captcha ¶
type Captcha struct {
// contains filtered or unexported fields
}
func NewCaptcha ¶
func NewCaptcha(cache interface_core.ICache) *Captcha
type DataBase ¶
type DataBase struct {
// contains filtered or unexported fields
}
func NewDataBase ¶
func NewDataBase() *DataBase
type DrawCenter ¶
type DrawCenter struct { Enable bool // contains filtered or unexported fields }
func NewDrawCenter ¶
func NewDrawCenter() *DrawCenter
func (*DrawCenter) Draw ¶
func (m *DrawCenter) Draw(actionId string, playerId string) (result model_draw.Result, err error)
执行抽奖
func (*DrawCenter) GetAction ¶
func (m *DrawCenter) GetAction(actionId string) (result model_draw.Action, err error)
获得活动信息
func (*DrawCenter) GetActionGifts ¶
func (m *DrawCenter) GetActionGifts(actionId string) (result []model_draw.Gift, err error)
获得活动奖品列表
func (*DrawCenter) GetActionWinners ¶
func (m *DrawCenter) GetActionWinners(actionId string) (result []model_draw.Player, err error)
func (*DrawCenter) GetGift ¶
func (m *DrawCenter) GetGift(actionId string, giftId string) (result model_draw.Gift, err error)
获得活动奖品信息(单个)
func (*DrawCenter) GetPlayer ¶
func (m *DrawCenter) GetPlayer(actionId string, playerId string) (result model_draw.Player, err error)
获得活动用户信息
func (*DrawCenter) GetPlayerGifts ¶
func (m *DrawCenter) GetPlayerGifts(actionId string, playerId string) (result []model_draw.Gift, err error)
获得用户已获得奖品列表
func (*DrawCenter) Verify ¶
func (m *DrawCenter) Verify(actionId string, playerId string, giftId string, verify bool) (result model_draw.VerifyResult, err error)
用户确认获奖
type JWTService ¶
type JWTService struct {
// contains filtered or unexported fields
}
func NewCustomJWT ¶
func NewCustomJWT(header string) *JWTService
func NewJWT ¶
func NewJWT() *JWTService
func (*JWTService) CreateToken ¶
func (m *JWTService) CreateToken(ctx iris.Context, claims interface{}) (token string, err error)
CreateToken 生成Token,默认存入Cookie中
func (*JWTService) FromCookie ¶
func (m *JWTService) FromCookie(ctx iris.Context) string
func (*JWTService) GetClaims ¶
func (m *JWTService) GetClaims(ctx iris.Context) (claims interface{})
GetClaims 验证Token并返回其中包含的Claims对象指针,需要在Middleware处理后才能获得,如需手动验证,请使用VerifyToken方法,强烈建议使用此方法
func (*JWTService) GetMiddleware ¶
func (m *JWTService) GetMiddleware() iris.Handler
GetMiddleware 获取iris路由中间件,用于验证请求合法性
func (*JWTService) RemoveToken ¶
func (m *JWTService) RemoveToken(ctx iris.Context)
RemoveToken 从Cookie中移除Token信息,一般用于"注销"功能
func (*JWTService) VerifyToken ¶
func (m *JWTService) VerifyToken(ctx iris.Context) (result *jwt.VerifiedToken, err error)
VerifyToken 从默认渠道(Cookie)中获取Token信息并验证,验证成功后返回VerifiedToken对象,仅用于手动验证,不建议使用
type LruCache ¶
type LruCache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe fixed size LRU cache.
func NewLruCache ¶
func NewLruCache() *LruCache
func NewWithEvict ¶
NewWithEvict constructs a fixed size cache with the given eviction callback.
func NewWithExpire ¶
NewWithExpire constructs a fixed size cache with expire feature
func (*LruCache) Contains ¶
Check if a key is in the cache, without updating the recent-ness or deleting it for being stale.
func (*LruCache) ContainsOrAdd ¶
ContainsOrAdd checks if a key is in the cache without updating the recent-ness or deleting it for being stale, and if not, adds the value. Returns whether found and whether an eviction occurred.
func (*LruCache) Keys ¶
func (c *LruCache) Keys() []interface{}
Keys returns a slice of the keys in the cache, from oldest to newest.
func (*LruCache) Peek ¶
Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.
func (*LruCache) Remove ¶
func (c *LruCache) Remove(key interface{})
Remove removes the provided key from the cache.
func (*LruCache) RemoveOldest ¶
func (c *LruCache) RemoveOldest()
RemoveOldest removes the oldest item from the cache.
type MsgCenter ¶
type MsgCenter struct {
// contains filtered or unexported fields
}
func NewMsgCenter ¶
func NewMsgCenter() *MsgCenter
func (*MsgCenter) CloseChannel ¶
func (*MsgCenter) CreateAppChannelId ¶
func (*MsgCenter) OpenChannel ¶
func (m *MsgCenter) OpenChannel(channelIds []string, onReceiveMsg func(*types.MsgContent)) (err error)
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(cache interface_core.ICache) (store *RedisStore)
func (*RedisStore) Set ¶
func (m *RedisStore) Set(id string, value string)
type SessionCache ¶
type SessionCache struct {
// contains filtered or unexported fields
}
func NewSessionCache ¶
func NewSessionCache(cache interface_core.ICache) *SessionCache
func (*SessionCache) Del ¶
func (m *SessionCache) Del(ctx iris.Context, key string) (result bool, err error)
func (*SessionCache) Exists ¶
func (m *SessionCache) Exists(ctx iris.Context, key string) (result bool, err error)
func (*SessionCache) Get ¶
func (m *SessionCache) Get(ctx iris.Context, key string) (result string, err error)
func (*SessionCache) GetCacheKey ¶
func (m *SessionCache) GetCacheKey(ctx iris.Context, key string) string
func (*SessionCache) Incr ¶
func (m *SessionCache) Incr(ctx iris.Context, key string) (result int64, err error)
func (*SessionCache) Md5 ¶
func (m *SessionCache) Md5(str string) string
type TaskCenter ¶
func NewTaskCenter ¶
func NewTaskCenter() *TaskCenter
func (*TaskCenter) GetClient ¶
func (m *TaskCenter) GetClient(clientPoolSize int) (result server.Client)
func (*TaskCenter) GetServer ¶
func (m *TaskCenter) GetServer() (result server.Server)
type WxAuth ¶
type WxAuth struct {
// contains filtered or unexported fields
}
func NewWxAuth ¶
func NewWxAuth(jwt interface_core.IJwtService, cache interface_core.ICache) *WxAuth
func (*WxAuth) GetCurrentUser ¶
func (m *WxAuth) GetCurrentUser(ctx iris.Context) (result *types.WxAuthInfo)