redis

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 5 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package redis is a simple redis cache implement. base on the package: https://github.com/gomodule/redigo

Example
package main

import (
	"fmt"

	"github.com/gookit/cache/redis"
)

func main() {
	// init driver
	c := redis.Connect("127.0.0.1:6379", "", 0)

	// set
	_ = c.Set("name", "cache value", 60)

	// get
	val := c.Get("name")

	// del
	_ = c.Del("name")

	// get: "cache value"
	fmt.Print(val)
}

Index

Examples

Constants

View Source
const Name = "redigo"

Name driver name

Variables

This section is empty.

Functions

This section is empty.

Types

type Redigo added in v0.2.0

type Redigo struct {
	cache.BaseDriver
	// contains filtered or unexported fields
}

Redigo driver definition. redigo doc link: https://pkg.go.dev/github.com/gomodule/redigo/redis#pkg-examples

func Connect

func Connect(url, pwd string, dbNum int) *Redigo

Connect create and connect to redis server

func New

func New(url, pwd string, dbNum int) *Redigo

New redis cache

func (*Redigo) Clear added in v0.2.0

func (c *Redigo) Clear() error

Clear all caches

func (*Redigo) Close added in v0.2.0

func (c *Redigo) Close() error

Close connection

func (*Redigo) Connect added in v0.2.0

func (c *Redigo) Connect() *Redigo

Connect to redis server

func (*Redigo) Del added in v0.2.0

func (c *Redigo) Del(key string) (err error)

Del value by key

func (*Redigo) DelMulti added in v0.2.0

func (c *Redigo) DelMulti(keys []string) (err error)

DelMulti values by keys

func (*Redigo) Get added in v0.2.0

func (c *Redigo) Get(key string) any

Get value by key

func (*Redigo) GetAs added in v0.2.0

func (c *Redigo) GetAs(key string, ptr any) error

GetAs get cache and unmarshal to ptr

func (*Redigo) GetMulti added in v0.2.0

func (c *Redigo) GetMulti(keys []string) map[string]any

GetMulti values by keys

func (*Redigo) Has added in v0.2.0

func (c *Redigo) Has(key string) bool

Has cache key

func (*Redigo) Pool added in v0.2.0

func (c *Redigo) Pool() *redis.Pool

Pool get

func (*Redigo) Set added in v0.2.0

func (c *Redigo) Set(key string, val any, ttl time.Duration) (err error)

Set value by key

func (*Redigo) SetMulti added in v0.2.0

func (c *Redigo) SetMulti(values map[string]any, ttl time.Duration) (err error)

SetMulti values

func (*Redigo) String added in v0.2.0

func (c *Redigo) String() string

String get

type RedisCache

type RedisCache = Redigo

RedisCache fallback alias

Jump to

Keyboard shortcuts

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