cache

package
v0.0.0-...-3d0adf2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : const.go # Created : 2019/1/14 11:03 # Last Modified : 2019/1/14 11:03 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : curd.go # Created : 2019/1/21 15:13 # Last Modified : 2019/1/21 15:13 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : getter.go # Created : 2019/1/11 17:48 # Last Modified : 2019/1/11 17:48 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : limit.go # Created : 2019/1/25 16:09 # Last Modified : 2019/1/25 16:09 # Describe : 限制短信发送频次 # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : list.go # Created : 2019/1/22 19:34 # Last Modified : 2019/1/22 19:34 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : local.go # Created : 2019/1/15 19:27 # Last Modified : 2019/1/15 19:27 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : lock.go # Created : 2019/1/18 17:35 # Last Modified : 2019/1/18 17:35 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : putter.go # Created : 2019/1/14 10:58 # Last Modified : 2019/1/14 10:58 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : transaction.go # Created : 2019/1/23 14:38 # Last Modified : 2019/1/23 14:38 # Describe : # # ====================================================

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLocalTemplate

func AddLocalTemplate(ctx context.Context, s string, v string) error

AddLocalTemplate 将模板添加到本地缓存, 因为当前模板是不可变的所以,默认缓存1小时,如果以后变动频繁,可以适当降低缓存刷新时间。

func BaseDetail

func BaseDetail(ctx context.Context, k string) ([]byte, error)

func BaseTemplate

func BaseTemplate(ctx context.Context, k string) (string, error)

func Detail

func Detail(ctx context.Context, id string) ([]byte, error)

func LLenMsg

func LLenMsg() (int64, error)

LLenMsg 查看入库队列的长度

func LPopMsg

func LPopMsg() ([]byte, error)

LPopMsg 从入库队列中取一条数据

func LastestDetail

func LastestDetail(ctx context.Context, k string) ([]byte, error)

func LocalTemplate

func LocalTemplate(ctx context.Context, s string) (string, error)

LocalTemplate 从本地缓存中取出模板

func LockID5s

func LockID5s(ctx context.Context, k string) error

LockID5s 独占锁

func LockId

func LockId(ctx context.Context, k string) error

LockId 当需要操作一个公共数据时需要使用lock,锁最多持有10秒钟

func PutBaseCache

func PutBaseCache(ctx context.Context, k string, v []byte) error

PutBaseCache 底层缓存,跟数据库数据同步,不过期

func PutBaseTemplate

func PutBaseTemplate(ctx context.Context, k string, v []byte) error

PutBaseTemplate 将添加的模板存入缓存中

func PutSendSuccess

func PutSendSuccess(ctx context.Context, k string) error

PutSendResult 在bitmap中修改发送结果,一般只有发送成功的情况才需要设置

func RPushMsg

func RPushMsg(ctx context.Context, b []byte) error

func RateLimit

func RateLimit(ctx context.Context, toUser string, sendTime time.Time) error

RateLimit 限速器,如果超过流量返回失败,sendDate格式2006-01-02,second为当天0点到该时的秒数

func ReleaseLock

func ReleaseLock(ctx context.Context, k string) error

ReleaseLock 释放独占锁

func RemoveLimit

func RemoveLimit(ctx context.Context, toUser string, sendTime time.Time) error

RemoveLimit 移除特定时间的限制

func SendResult

func SendResult(ctx context.Context, k string) (bool, error)

SendResult 获取发送结果

func UnlockId

func UnlockId(ctx context.Context, k string) error

UnlockId 释放id锁

Types

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
}

type Transaction

type Transaction struct {
	C *redis.Client
}

func NewTransaction

func NewTransaction() *Transaction

func (*Transaction) Close

func (t *Transaction) Close() error

func (*Transaction) Commit

func (t *Transaction) Commit(ctx context.Context) error

Commit 提交事务

func (*Transaction) CommitParam

func (t *Transaction) CommitParam(ctx context.Context) ([]interface{}, error)

CommitParam 待参数的提交

func (*Transaction) LPopMsg

func (t *Transaction) LPopMsg() ([]byte, error)

LPopMsg 从msg队列中取一条数据

func (*Transaction) PutBaseCache

func (t *Transaction) PutBaseCache(ctx context.Context, k string, v []byte) error

PutBaseCache 底层缓存,跟数据库数据同步,不过期

func (*Transaction) PutBaseTemplate

func (t *Transaction) PutBaseTemplate(ctx context.Context, k string, v []byte) error

PutBaseTemplate 将添加的模板存入缓存中

func (*Transaction) PutSendSuccess

func (t *Transaction) PutSendSuccess(ctx context.Context, k string) error

PutSendResult 修改发送结果,一般只有发送成功的情况才需要设置

func (*Transaction) RPushMsg

func (t *Transaction) RPushMsg(ctx context.Context, b []byte) error

RPushMsg 将消息存入list中,用于异步存入数据库

func (*Transaction) Rollback

func (t *Transaction) Rollback(ctx context.Context) error

Rollback 回滚事务

Jump to

Keyboard shortcuts

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