redkacli

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 7 Imported by: 0

README

Redka 客户端

一个 Redka 客户端,使用体验更像在使用 Redis 客户端。

特征

快速开始

先决条件

Redka Client 要求 Go 版本 1.22 或以上。

获取 Redka Client
import "github.com/hugiot/redkacli"

或者

go get -u github.com/hugiot/redkacli
运行
package main

import (
	"fmt"
	"github.com/hugiot/redkacli"
	"log"
)

func main() {
	options := redkacli.NewOptions()
	options.SetPath("./test.db")
	client, err := redkacli.New(options)
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	// string commands
	_ = client.Set("name", "Tom")
	fmt.Println(client.Get("name"))

	// hash commands
	_, _ = client.HSet("object", map[string]interface{}{
		"name": "Tom",
		"age":  10,
		"city": "New York",
	})
	fmt.Println(client.HGetAll("object"))
	
	// other commands
	// ……
}

感谢

许可证

2025 © hugiot. This project is MIT licensed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(o *Options) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) DBSize

func (c *Client) DBSize() (int64, error)

func (*Client) Decr

func (c *Client) Decr(key string) (int64, error)

func (*Client) DecrBy

func (c *Client) DecrBy(key string, increment int64) (int64, error)

func (*Client) DecrByFloat

func (c *Client) DecrByFloat(key string, increment float64) (float64, error)

func (*Client) Del

func (c *Client) Del(keys ...string) (int64, error)

func (*Client) Echo

func (c *Client) Echo(message string) (string, error)

func (*Client) Exists

func (c *Client) Exists(key string) (bool, error)

func (*Client) Expire

func (c *Client) Expire(key string, seconds int64) error

func (*Client) ExpireAt

func (c *Client) ExpireAt(key string, timestamp int64) error

func (*Client) FlushAll

func (c *Client) FlushAll() error

func (*Client) FlushDB

func (c *Client) FlushDB() error

func (*Client) Get

func (c *Client) Get(key string) (string, error)

func (*Client) GetSet

func (c *Client) GetSet(key string, value interface{}) (old string, err error)

func (*Client) HDel

func (c *Client) HDel(key string, fields ...string) (int64, error)

func (*Client) HExists

func (c *Client) HExists(key string, field string) (bool, error)

func (*Client) HGet

func (c *Client) HGet(key string, field string) (string, error)

func (*Client) HGetAll

func (c *Client) HGetAll(key string) (map[string]string, error)

func (*Client) HIncrBy

func (c *Client) HIncrBy(key string, field string, increment int) (int64, error)

func (*Client) HIncrByFloat

func (c *Client) HIncrByFloat(key string, field string, increment float64) (float64, error)

func (*Client) HKeys

func (c *Client) HKeys(key string) ([]string, error)

func (*Client) HLen

func (c *Client) HLen(key string) (int64, error)

func (*Client) HMGet

func (c *Client) HMGet(key string, fields ...string) (map[string]string, error)

func (*Client) HMSet

func (c *Client) HMSet(key string, values map[string]interface{}) (bool, error)

func (*Client) HScan

func (c *Client) HScan(key string, cursor int, match string, count int) (map[string]string, int, error)

func (*Client) HSet

func (c *Client) HSet(key string, fields map[string]interface{}) (int64, error)

func (*Client) HSetNX

func (c *Client) HSetNX(key string, field string, value interface{}) (bool, error)

func (*Client) HVals

func (c *Client) HVals(key string) ([]string, error)

func (*Client) Incr

func (c *Client) Incr(key string) (int64, error)

func (*Client) IncrBy

func (c *Client) IncrBy(key string, increment int64) (int64, error)

func (*Client) IncrByFloat

func (c *Client) IncrByFloat(key string, increment float64) (float64, error)

func (*Client) Keys

func (c *Client) Keys(pattern string) ([]string, error)

func (*Client) LIndex

func (c *Client) LIndex(key string, index int) (string, error)

func (*Client) LInsert

func (c *Client) LInsert(key string, op string, pivot string, value string) (int64, error)

func (*Client) LLen

func (c *Client) LLen(key string) (int64, error)

func (*Client) LOLWUT

func (c *Client) LOLWUT() (string, error)

func (*Client) LPop

func (c *Client) LPop(key string) (string, error)

func (*Client) LPush

func (c *Client) LPush(key string, elements ...interface{}) (int64, error)

func (*Client) LRange

func (c *Client) LRange(key string, start int64, stop int64) ([]string, error)

func (*Client) LRem

func (c *Client) LRem(key string, count int, element string) (int64, error)

func (*Client) LSet

func (c *Client) LSet(key string, index int, element string) error

func (*Client) LTrim

func (c *Client) LTrim(key string, start, stop int64) (int64, error)

func (*Client) MGet

func (c *Client) MGet(keys ...string) (map[string]string, error)

func (*Client) MSet

func (c *Client) MSet(kv map[string]interface{}) error

func (*Client) PExpire

func (c *Client) PExpire(key string, milliseconds int64) error

func (*Client) PExpireAt

func (c *Client) PExpireAt(key string, timestamp int64) error

func (*Client) PSetEx

func (c *Client) PSetEx(key string, value interface{}, milliseconds int64) error

func (*Client) Persist

func (c *Client) Persist(key string) error

func (*Client) Ping

func (c *Client) Ping() (string, error)

func (*Client) RPop

func (c *Client) RPop(key string) (string, error)

func (*Client) RPopLPush

func (c *Client) RPopLPush(source string, destination string) (string, error)

func (*Client) RPush

func (c *Client) RPush(key string, elements ...interface{}) (int64, error)

func (*Client) RandomKey

func (c *Client) RandomKey() (string, error)

func (*Client) Rename

func (c *Client) Rename(key, newKey string) error

func (*Client) RenameNX

func (c *Client) RenameNX(key, newKey string) (bool, error)

func (*Client) SAdd

func (c *Client) SAdd(key string, members ...interface{}) (int64, error)

func (*Client) SCard

func (c *Client) SCard(key string) (int64, error)

func (*Client) SDiff

func (c *Client) SDiff(keys ...string) ([]string, error)

func (*Client) SDiffStore

func (c *Client) SDiffStore(destination string, keys ...string) (int64, error)

func (*Client) SInter

func (c *Client) SInter(keys ...string) ([]string, error)

func (*Client) SInterStore

func (c *Client) SInterStore(destination string, keys ...string) (int64, error)

func (*Client) SIsMember

func (c *Client) SIsMember(key string, member interface{}) (bool, error)

func (*Client) SMembers

func (c *Client) SMembers(key string) ([]string, error)

func (*Client) SMove

func (c *Client) SMove(source, destination string, member interface{}) error

func (*Client) SPop

func (c *Client) SPop(key string) (string, error)

func (*Client) SRandMember

func (c *Client) SRandMember(key string) (string, error)

func (*Client) SRem

func (c *Client) SRem(key string, members ...interface{}) (int64, error)

func (*Client) SScan

func (c *Client) SScan(key string, cursor uint64, match string, count int64) ([]string, uint64, error)

func (*Client) SUnion

func (c *Client) SUnion(keys ...string) ([]string, error)

func (*Client) SUnionStore

func (c *Client) SUnionStore(destination string, keys ...string) (int64, error)

func (*Client) Scan

func (c *Client) Scan(cursor int, match string, count int) ([]string, int, error)

func (*Client) Select

func (c *Client) Select(index int) error

func (*Client) Set

func (c *Client) Set(key string, value interface{}) error

func (*Client) SetEx

func (c *Client) SetEx(key string, value interface{}, seconds int64) error

func (*Client) SetNX

func (c *Client) SetNX(key string, value interface{}, seconds int64) (bool, error)

func (*Client) StrLen

func (c *Client) StrLen(key string) (int64, error)

func (*Client) TTL

func (c *Client) TTL(key string) (int64, error)

func (*Client) Transaction

func (c *Client) Transaction(f func(tx *redka.Tx) error) error

func (*Client) TransactionContext

func (c *Client) TransactionContext(ctx context.Context, f func(tx *redka.Tx) error) error

func (*Client) Type

func (c *Client) Type(key string) (string, error)

func (*Client) ZAdd

func (c *Client) ZAdd(key string, members map[interface{}]float64) (int64, error)

func (*Client) ZCard

func (c *Client) ZCard(key string) (int64, error)

func (*Client) ZCount

func (c *Client) ZCount(key string, min, max float64) (int64, error)

func (*Client) ZIncrBy

func (c *Client) ZIncrBy(key string, increment float64, member string) (float64, error)

func (*Client) ZInter

func (c *Client) ZInter(keys ...string) ([]string, error)

func (*Client) ZInterStore

func (c *Client) ZInterStore(destination string, keys ...string) (int64, error)

func (*Client) ZRange

func (c *Client) ZRange(key string, start, stop int64) ([]string, error)

func (*Client) ZRangeByScore

func (c *Client) ZRangeByScore(key string, min, max float64) ([]string, error)

func (*Client) ZRank

func (c *Client) ZRank(key, member string) (int64, error)

func (*Client) ZRankWithScore

func (c *Client) ZRankWithScore(key, member string) (int64, float64, error)

func (*Client) ZRem

func (c *Client) ZRem(key string, members ...interface{}) (int64, error)

func (*Client) ZRemRangeByRank

func (c *Client) ZRemRangeByRank(key string, start, stop int64) (int64, error)

func (*Client) ZRemRangeByScore

func (c *Client) ZRemRangeByScore(key string, min, max float64) (int64, error)

func (*Client) ZRevRange

func (c *Client) ZRevRange(key string, start, stop int64) ([]string, error)

func (*Client) ZRevRangeByScore

func (c *Client) ZRevRangeByScore(key string, min, max float64) ([]string, error)

func (*Client) ZRevRank

func (c *Client) ZRevRank(key, member string) (int64, error)

func (*Client) ZRevRankWithScore

func (c *Client) ZRevRankWithScore(key, member string) (int64, float64, error)

func (*Client) ZScan

func (c *Client) ZScan(key string, cursor uint64, match string, count int64) ([]string, uint64, error)

func (*Client) ZScore

func (c *Client) ZScore(key, member string) (float64, error)

func (*Client) ZUnion

func (c *Client) ZUnion(keys ...string) ([]string, error)

func (*Client) ZUnionStore

func (c *Client) ZUnionStore(destination string, keys ...string) (int64, error)

func (*Client) ZUnionWithScore

func (c *Client) ZUnionWithScore(keys ...string) (map[string]float64, error)

type Options

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

func NewOptions

func NewOptions() *Options

func (*Options) AddPragma

func (opts *Options) AddPragma(key, value string)

func (*Options) SetDriverName

func (opts *Options) SetDriverName(driverName string)

func (*Options) SetLogger

func (opts *Options) SetLogger(logger *slog.Logger)

func (*Options) SetPath

func (opts *Options) SetPath(path string)

func (*Options) SetPragma

func (opts *Options) SetPragma(pragma map[string]string)

Jump to

Keyboard shortcuts

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