sqlredis

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 6 Imported by: 0

README

思路

  1. 插入。先插入到 mysql,然后插入到 redis。
  2. 删除。先从 mysql 中删除,然后从 redis 中删除。
  3. 更新。先更新 mysql,然后从 redis 中删除。
  4. 查询。先从 redis 中读取,如果出错,则从 mysql 中读取。如果没有出错,但 redis 中不存在,则从 mysql 中读取,如果 mysql 中存在,则 redis 中保存一份。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SqlRedis

type SqlRedis struct {
	SqlOrm   *mysql.SimpleOrm
	RedisOrm *redis.SimpleOrm
}

func (*SqlRedis) DeleteById

func (sr *SqlRedis) DeleteById(tableName, entityName, redisKeyPrefix string, id int64) (bool, error)

func (*SqlRedis) GetById

func (sr *SqlRedis) GetById(tableName, entityName, redisKeyPrefix string, id, expireSeconds int64, entityPtr interface{}) (bool, error)

func (*SqlRedis) Insert

func (sr *SqlRedis) Insert(tableName, entityName, idFieldName, redisKeyPrefix string, expireSeconds int64, entities ...interface{}) ([]int64, error)

func (*SqlRedis) RedisKeyForEntity

func (sr *SqlRedis) RedisKeyForEntity(id interface{}, prefix, entityName string) string

func (*SqlRedis) RedisKeyForTotalRows

func (sr *SqlRedis) RedisKeyForTotalRows(tableName, redisKeyPrefix string) string

func (*SqlRedis) TotalRows

func (sr *SqlRedis) TotalRows(tableName, redisKeyPrefix string, expireSeconds int64) (int64, error)

func (*SqlRedis) UpdateById

func (sr *SqlRedis) UpdateById(tableName, entityName, redisKeyPrefix string, id int64, newEntityPtr interface{}, updateFields map[string]bool, expireSeconds int64) ([]*mysql.QueryItem, error)

func (*SqlRedis) UpdateEntity

func (sr *SqlRedis) UpdateEntity(redisKey string, setItems []*mysql.QueryItem, expireSeconds int64) error

Jump to

Keyboard shortcuts

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