Documentation ¶
Index ¶
- Constants
- type DataProcessor
- type RedisManager
- func (r *RedisManager) GetClient() redis.UniversalClient
- func (r *RedisManager) GetData(ctx context.Context, key string) ([]string, error)
- func (r *RedisManager) GetDataByLatest(ctx context.Context, key string) (string, error)
- func (r *RedisManager) GetDataByPage(ctx context.Context, deviceKey string, pageNum, pageSize int, ...) (res []string, total, currentPage int, err error)
- func (r *RedisManager) GetDbname() string
- func (r *RedisManager) InsertBatchData(ctx context.Context, key string, data []interface{}) error
- func (r *RedisManager) InsertData(ctx context.Context, key string, data interface{}, buffer bool) (err error)
- func (r *RedisManager) ListenForNewData(ctx context.Context, key string, processor DataProcessor, ...)
Constants ¶
View Source
const ( DeviceDataCachePrefix = "deviceCacheData:" // 设备数据缓存前缀 ModeSingle = "single" ModeCluster = "cluster" ModeSentinel = "sentinel" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisManager ¶
type RedisManager struct {
// contains filtered or unexported fields
}
RedisManager 管理Redis操作和连接池
func (*RedisManager) GetClient ¶
func (r *RedisManager) GetClient() redis.UniversalClient
GetClient 获取Redis客户端
func (*RedisManager) GetDataByLatest ¶
GetDataByLatest 获取最新的一条数据
func (*RedisManager) GetDataByPage ¶
func (r *RedisManager) GetDataByPage(ctx context.Context, deviceKey string, pageNum, pageSize int, types, dateRange []string) (res []string, total, currentPage int, err error)
GetDataByPage 按分页获取数据,增加按字段内容搜索和时间区间搜索
func (*RedisManager) GetDbname ¶
func (r *RedisManager) GetDbname() string
func (*RedisManager) InsertBatchData ¶
func (r *RedisManager) InsertBatchData(ctx context.Context, key string, data []interface{}) error
InsertBatchData 批量插入数据到Redis
func (*RedisManager) InsertData ¶
func (r *RedisManager) InsertData(ctx context.Context, key string, data interface{}, buffer bool) (err error)
InsertData 插入单条数据到Redis
func (*RedisManager) ListenForNewData ¶
func (r *RedisManager) ListenForNewData(ctx context.Context, key string, processor DataProcessor, interval time.Duration)
ListenForNewData 监听指定的 Redis key,对新数据执行处理函数,interval为轮询间隔
Click to show internal directories.
Click to hide internal directories.