// Package diagram provide diagram data structure and operation package diagram import ( "context" "github.com/redis/go-redis/v9" ) // RedisClient define struct to create redis client type RedisClient struct { Client *redis.Client } // NewRedisClient define func of new redis client instance func NewRedisClient() *RedisClient { return &RedisClient{ Client: GetRedisClientInstance(), } } // QueryByZRangeByLex define func to query real time data from redis zset func (rc *RedisClient) QueryByZRangeByLex(ctx context.Context, key string, size int64, startTimestamp, stopTimeStamp string) ([]redis.Z, error) { client := rc.Client startStr := "[" + startTimestamp stopStr := stopTimeStamp + "]" args := redis.ZRangeArgs{ Key: key, Start: startStr, Stop: stopStr, ByLex: true, Rev: false, Count: size, } return client.ZRangeArgsWithScores(ctx, args).Result() }