redis

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 6 Imported by: 0

README

redis

Go Report Card tests GoDoc MIT license

——The idea came from Laravel

Usage

package main

import (
	"github.com/go-packagist/framework/config"
	"github.com/go-packagist/framework/foundation"
	"github.com/go-packagist/framework/redis"
	"github.com/go-packagist/framework/support/facades"
)

func main() {
	app := foundation.NewApplication("./")

	app.Register(config.NewConfigProvider(app))

	facades.MustConfig().Add("redis", map[string]interface{}{
		"default": "redis",
		"connections": map[string]interface{}{
			"redis": map[string]interface{}{
				"driver":   "redis",
				"host":     "localhost",
				"port":     63790,
				"database": 0,
				"password": "",
			},
		},
	})

	app.Register(redis.NewRedisProvider(app))

	facades.MustRedis().Connection().Set("key", "value", time.Second*100)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisProvider

func NewRedisProvider(app *foundation.Application) foundation.Provider

Types

type Connection

type Connection interface {
	Connect(map[string]interface{})
	Set(string, interface{}, time.Duration) (string, error)
	Get(string) (string, error)
	Echo(string) (string, error)
	Ping() (string, error)
	Del(...string) (int64, error)
	Exists(...string) (int64, error)
}

func NewRedisClusterConnection

func NewRedisClusterConnection() Connection

NewRedisClusterConnection creates a new redis connection.

func NewRedisConnection

func NewRedisConnection() Connection

NewRedisConnection creates a new redis connection.

type Manager

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

func NewManager

func NewManager(app *foundation.Application) *Manager

func (*Manager) Connection

func (m *Manager) Connection(name ...string) Connection

type RedisClusterConnection

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

RedisClusterConnection is a connection to a redis database.

func (*RedisClusterConnection) Append

func (c *RedisClusterConnection) Append(key, value string) (int64, error)

func (*RedisClusterConnection) Connect

func (c *RedisClusterConnection) Connect(config map[string]interface{})

Connect connects to the redis database.

func (*RedisClusterConnection) DBSize

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

func (*RedisClusterConnection) Decr

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

func (*RedisClusterConnection) DecrBy

func (c *RedisClusterConnection) DecrBy(key string, decrement int64) (int64, error)

func (*RedisClusterConnection) Del

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

Del deletes the given keys.

c.Del("key1", "key2")
c.Del("key3")

func (*RedisClusterConnection) Echo

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

Echo returns the given string.

func (*RedisClusterConnection) Exists

func (c *RedisClusterConnection) Exists(keys ...string) (int64, error)

func (*RedisClusterConnection) Expire

func (c *RedisClusterConnection) Expire(key string, expiration time.Duration) (bool, error)

func (*RedisClusterConnection) ExpireAt

func (c *RedisClusterConnection) ExpireAt(key string, tm time.Time) (bool, error)

func (*RedisClusterConnection) ExpireGT

func (c *RedisClusterConnection) ExpireGT(key string, expiration time.Duration) (bool, error)

func (*RedisClusterConnection) ExpireLT

func (c *RedisClusterConnection) ExpireLT(key string, expiration time.Duration) (bool, error)

func (*RedisClusterConnection) ExpireNX

func (c *RedisClusterConnection) ExpireNX(key string, expiration time.Duration) (bool, error)

func (*RedisClusterConnection) ExpireXX

func (c *RedisClusterConnection) ExpireXX(key string, expiration time.Duration) (bool, error)

func (*RedisClusterConnection) Get

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

func (*RedisClusterConnection) GetDel

func (c *RedisClusterConnection) GetDel(key string) (string, error)

func (*RedisClusterConnection) GetEx

func (c *RedisClusterConnection) GetEx(key string, expiration time.Duration) (string, error)

func (*RedisClusterConnection) GetRange

func (c *RedisClusterConnection) GetRange(key string, start, end int64) (string, error)

func (*RedisClusterConnection) GetSet

func (c *RedisClusterConnection) GetSet(key string, value interface{}) (string, error)

func (*RedisClusterConnection) Incr

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

func (*RedisClusterConnection) IncrBy

func (c *RedisClusterConnection) IncrBy(key string, value int64) (int64, error)

func (*RedisClusterConnection) IncrByFloat

func (c *RedisClusterConnection) IncrByFloat(key string, value float64) (float64, error)

func (*RedisClusterConnection) Keys

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

func (*RedisClusterConnection) MGet

func (c *RedisClusterConnection) MGet(keys ...string) ([]interface{}, error)

func (*RedisClusterConnection) MSet

func (c *RedisClusterConnection) MSet(values ...interface{}) (string, error)

func (*RedisClusterConnection) MSetNX

func (c *RedisClusterConnection) MSetNX(values ...interface{}) (bool, error)

func (*RedisClusterConnection) Migrate

func (c *RedisClusterConnection) Migrate(host, port, key string, db int, timeout time.Duration) (string, error)

func (*RedisClusterConnection) Move

func (c *RedisClusterConnection) Move(key string, db int) (bool, error)

func (*RedisClusterConnection) PExpire

func (c *RedisClusterConnection) PExpire(key string, expiration time.Duration) (bool, error)

func (*RedisClusterConnection) PExpireAt

func (c *RedisClusterConnection) PExpireAt(key string, tm time.Time) (bool, error)

func (*RedisClusterConnection) PTTL

func (*RedisClusterConnection) Persist

func (c *RedisClusterConnection) Persist(key string) (bool, error)

func (*RedisClusterConnection) Ping

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

Ping returns the redis ping.

func (*RedisClusterConnection) RandomKey

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

func (*RedisClusterConnection) Rename

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

func (*RedisClusterConnection) RenameNX

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

func (*RedisClusterConnection) Restore

func (c *RedisClusterConnection) Restore(key string, ttl time.Duration, value string) (string, error)

func (*RedisClusterConnection) RestoreReplace

func (c *RedisClusterConnection) RestoreReplace(key string, ttl time.Duration, value string) (string, error)

func (*RedisClusterConnection) Set

func (c *RedisClusterConnection) Set(key string, value interface{}, expiration time.Duration) (string, error)

func (*RedisClusterConnection) Sort

func (c *RedisClusterConnection) Sort(key string, sort *r.Sort) ([]string, error)

func (*RedisClusterConnection) SortInterfaces

func (c *RedisClusterConnection) SortInterfaces(key string, sort *r.Sort) ([]interface{}, error)

func (*RedisClusterConnection) SortStore

func (c *RedisClusterConnection) SortStore(key, store string, sort *r.Sort) (int64, error)

func (*RedisClusterConnection) TTL

func (*RedisClusterConnection) Touch

func (c *RedisClusterConnection) Touch(keys ...string) (int64, error)

func (*RedisClusterConnection) Type

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

type RedisConnection

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

RedisConnection is a connection to a redis database.

func (*RedisConnection) Append

func (c *RedisConnection) Append(key, value string) (int64, error)

func (*RedisConnection) Connect

func (c *RedisConnection) Connect(config map[string]interface{})

Connect connects to the redis database.

func (*RedisConnection) DBSize

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

func (*RedisConnection) Decr

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

func (*RedisConnection) DecrBy

func (c *RedisConnection) DecrBy(key string, decrement int64) (int64, error)

func (*RedisConnection) Del

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

Del deletes the given keys.

c.Del("key1", "key2")
c.Del("key3")

func (*RedisConnection) Echo

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

Echo returns the given string.

func (*RedisConnection) Exists

func (c *RedisConnection) Exists(keys ...string) (int64, error)

func (*RedisConnection) Expire

func (c *RedisConnection) Expire(key string, expiration time.Duration) (bool, error)

func (*RedisConnection) ExpireAt

func (c *RedisConnection) ExpireAt(key string, tm time.Time) (bool, error)

func (*RedisConnection) ExpireGT

func (c *RedisConnection) ExpireGT(key string, expiration time.Duration) (bool, error)

func (*RedisConnection) ExpireLT

func (c *RedisConnection) ExpireLT(key string, expiration time.Duration) (bool, error)

func (*RedisConnection) ExpireNX

func (c *RedisConnection) ExpireNX(key string, expiration time.Duration) (bool, error)

func (*RedisConnection) ExpireXX

func (c *RedisConnection) ExpireXX(key string, expiration time.Duration) (bool, error)

func (*RedisConnection) Get

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

func (*RedisConnection) GetDel

func (c *RedisConnection) GetDel(key string) (string, error)

func (*RedisConnection) GetEx

func (c *RedisConnection) GetEx(key string, expiration time.Duration) (string, error)

func (*RedisConnection) GetRange

func (c *RedisConnection) GetRange(key string, start, end int64) (string, error)

func (*RedisConnection) GetSet

func (c *RedisConnection) GetSet(key string, value interface{}) (string, error)

func (*RedisConnection) Incr

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

func (*RedisConnection) IncrBy

func (c *RedisConnection) IncrBy(key string, value int64) (int64, error)

func (*RedisConnection) IncrByFloat

func (c *RedisConnection) IncrByFloat(key string, value float64) (float64, error)

func (*RedisConnection) Keys

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

func (*RedisConnection) MGet

func (c *RedisConnection) MGet(keys ...string) ([]interface{}, error)

func (*RedisConnection) MSet

func (c *RedisConnection) MSet(values ...interface{}) (string, error)

func (*RedisConnection) MSetNX

func (c *RedisConnection) MSetNX(values ...interface{}) (bool, error)

func (*RedisConnection) Migrate

func (c *RedisConnection) Migrate(host, port, key string, db int, timeout time.Duration) (string, error)

func (*RedisConnection) Move

func (c *RedisConnection) Move(key string, db int) (bool, error)

func (*RedisConnection) PExpire

func (c *RedisConnection) PExpire(key string, expiration time.Duration) (bool, error)

func (*RedisConnection) PExpireAt

func (c *RedisConnection) PExpireAt(key string, tm time.Time) (bool, error)

func (*RedisConnection) PTTL

func (c *RedisConnection) PTTL(key string) (time.Duration, error)

func (*RedisConnection) Persist

func (c *RedisConnection) Persist(key string) (bool, error)

func (*RedisConnection) Ping

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

Ping returns the redis ping.

func (*RedisConnection) RandomKey

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

func (*RedisConnection) Rename

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

func (*RedisConnection) RenameNX

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

func (*RedisConnection) Restore

func (c *RedisConnection) Restore(key string, ttl time.Duration, value string) (string, error)

func (*RedisConnection) RestoreReplace

func (c *RedisConnection) RestoreReplace(key string, ttl time.Duration, value string) (string, error)

func (*RedisConnection) Set

func (c *RedisConnection) Set(key string, value interface{}, expiration time.Duration) (string, error)

func (*RedisConnection) Sort

func (c *RedisConnection) Sort(key string, sort *r.Sort) ([]string, error)

func (*RedisConnection) SortInterfaces

func (c *RedisConnection) SortInterfaces(key string, sort *r.Sort) ([]interface{}, error)

func (*RedisConnection) SortStore

func (c *RedisConnection) SortStore(key, store string, sort *r.Sort) (int64, error)

func (*RedisConnection) TTL

func (c *RedisConnection) TTL(key string) (time.Duration, error)

func (*RedisConnection) Touch

func (c *RedisConnection) Touch(keys ...string) (int64, error)

func (*RedisConnection) Type

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

Jump to

Keyboard shortcuts

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