redigo

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 3 Imported by: 0

README

redigo

An officially supported adapter compatible with redigo

Usage

package main

import (
	"log"

	"github.com/aidenwallis/go-ratelimiting/redis"
	"github.com/aidenwallis/go-ratelimiting/redis/adapters/redigo"
	redigo "github.com/gomodule/redigo/redis"
)

func main() {
	conn, err := redis.Dial("tcp", "127.0.0.1:6379")
	if err != nil {
		log.Fatalf("failed to connect to redis: %w", err)
	}

	ratelimiter := redis.NewLeakyBucket(redigo.NewAdapter(conn))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Conn redis.Conn
}

Adapter is a redigo implementation compatible with github.com/aidenwallis/go-ratelimiting/redis/adapters

func NewAdapter

func NewAdapter(conn redis.Conn) *Adapter

NewAdapter creates a new adapter using the redigo client.

func (*Adapter) Eval

func (a *Adapter) Eval(ctx context.Context, script string, keys []string, args []interface{}) (interface{}, error)

Eval defines adapter compatibility for the redis EVAL command

Jump to

Keyboard shortcuts

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