service_core

package
v0.0.0-...-294a70e Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: Apache-2.0 Imports: 32 Imported by: 0

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

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 NewCache

func NewCache() *Cache

func NewCacheByConfig

func NewCacheByConfig(config CacheConfig) *Cache

func (*Cache) CreateKey

func (m *Cache) CreateKey(key string) string

func (*Cache) Decr

func (m *Cache) Decr(key string) (result int64, err error)

func (*Cache) Del

func (m *Cache) Del(key string) (result bool, err error)

func (*Cache) Exists

func (m *Cache) Exists(key string) (result bool, err error)

func (*Cache) Get

func (m *Cache) Get(key string) (result string, err error)

func (*Cache) GetBackend

func (m *Cache) GetBackend() (result *redis.Client, err error)

func (*Cache) Incr

func (m *Cache) Incr(key string) (result int64, err error)

func (*Cache) Md5

func (m *Cache) Md5(str string) string

func (*Cache) Set

func (m *Cache) Set(key string, value string) (result string, err error)

func (*Cache) SetEx

func (m *Cache) SetEx(key string, value string, ttl time.Duration) (result string, err error)

type CacheConfig

type CacheConfig struct {
	AppName  string
	Server   string
	Password string
	DataBase int
	PoolSize int
}

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

func (*Captcha) New

func (m *Captcha) New() (result *types.Captcha, err error)

func (*Captcha) Reload

func (m *Captcha) Reload(id string) (result *types.Captcha, err error)

func (*Captcha) Verify

func (m *Captcha) Verify(id string, digits string) (result bool, err error)

type Channel

type Channel struct {
	// contains filtered or unexported fields
}

type DataBase

type DataBase struct {
	// contains filtered or unexported fields
}

func NewDataBase

func NewDataBase() *DataBase

func (*DataBase) GetDB

func (m *DataBase) GetDB() *gorm.DB

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 New

func New(size int) (*LruCache, error)

New creates an LRU of the given size

func NewLruCache

func NewLruCache() *LruCache

func NewWithEvict

func NewWithEvict(size int, onEvicted func(key interface{}, value interface{})) (*LruCache, error)

NewWithEvict constructs a fixed size cache with the given eviction callback.

func NewWithExpire

func NewWithExpire(size int, expire time.Duration) (*LruCache, error)

NewWithExpire constructs a fixed size cache with expire feature

func (*LruCache) Add

func (c *LruCache) Add(key, value interface{}) bool

Add adds a value to the cache. Returns true if an eviction occurred.

func (*LruCache) AddEx

func (c *LruCache) AddEx(key, value interface{}, expire time.Duration) bool

AddEx adds a value to the cache. Returns true if an eviction occurred.

func (*LruCache) Contains

func (c *LruCache) Contains(key interface{}) bool

Check if a key is in the cache, without updating the recent-ness or deleting it for being stale.

func (*LruCache) ContainsOrAdd

func (c *LruCache) ContainsOrAdd(key, value interface{}) (ok, evict bool)

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) Get

func (c *LruCache) Get(key interface{}) (interface{}, bool)

Get looks up a key's value from the cache.

func (*LruCache) Keys

func (c *LruCache) Keys() []interface{}

Keys returns a slice of the keys in the cache, from oldest to newest.

func (*LruCache) Len

func (c *LruCache) Len() int

Len returns the number of items in the cache.

func (*LruCache) Peek

func (c *LruCache) Peek(key interface{}) (interface{}, bool)

Returns the key value (or undefined if not found) without updating the "recently used"-ness of the key.

func (*LruCache) Purge

func (c *LruCache) Purge()

Purge is used to completely clear the cache

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 (m *MsgCenter) CloseChannel(channelIds []string) (err error)

func (*MsgCenter) CreateAppChannelId

func (m *MsgCenter) CreateAppChannelId(channelId string) (result string, err error)

func (*MsgCenter) OpenChannel

func (m *MsgCenter) OpenChannel(channelIds []string, onReceiveMsg func(*types.MsgContent)) (err error)

func (*MsgCenter) SendMsg

func (m *MsgCenter) SendMsg(channelId, msgType, msg string) (err error)

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

func NewRedisStore

func NewRedisStore(cache interface_core.ICache) (store *RedisStore)

func (*RedisStore) Get

func (m *RedisStore) Get(id string, clear bool) string

func (*RedisStore) Set

func (m *RedisStore) Set(id string, value string)

func (*RedisStore) Verify

func (m *RedisStore) Verify(id, answer string, clear bool) bool

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

func (*SessionCache) Set

func (m *SessionCache) Set(ctx iris.Context, key string, value string, ttl time.Duration) (result string, err error)

type TaskCenter

type TaskCenter struct {
	Server *server.Server
}

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 (*WxAuth) CheckAuth

func (m *WxAuth) CheckAuth(ctx iris.Context, returnUrl string) (result bool)

func (*WxAuth) DoAuth

func (m *WxAuth) DoAuth(ctx iris.Context)

func (*WxAuth) GetCurrentUser

func (m *WxAuth) GetCurrentUser(ctx iris.Context) (result *types.WxAuthInfo)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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