redis

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package redis provides a Redis-based implementation of the route table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmdable added in v0.0.7

type Cmdable interface {
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	GetSet(ctx context.Context, key string, value interface{}) *redis.StringCmd
	SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd
	Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
}

Cmdable is an interface that represents Redis command execution capability.

type RouteTable added in v0.0.7

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

RouteTable implements the routetable.Data interface using Redis.

func New added in v0.0.7

func New(client Cmdable) *RouteTable

New creates a new Redis-based route table data store.

func (*RouteTable) Del added in v0.0.7

func (r *RouteTable) Del(ctx context.Context, key string) error

Del deletes a key from Redis.

func (*RouteTable) DelIfSame added in v0.0.7

func (r *RouteTable) DelIfSame(ctx context.Context, key, expect string) error

DelIfSame deletes a key only if its current value matches the specified value.

func (*RouteTable) Expire added in v0.0.7

func (r *RouteTable) Expire(ctx context.Context, key string, expire time.Duration) error

Expire sets an expiration time for a key.

func (*RouteTable) GetSet added in v0.0.7

func (r *RouteTable) GetSet(ctx context.Context, key, val string, expire time.Duration) (string, error)

GetSet atomically sets a new value and returns the old value.

func (*RouteTable) Load added in v0.0.7

func (r *RouteTable) Load(ctx context.Context, key string) (string, error)

Load retrieves a value from Redis by key.

func (*RouteTable) LoadAndExpire added in v0.0.7

func (r *RouteTable) LoadAndExpire(ctx context.Context, key string, expire time.Duration) (string, error)

LoadAndExpire loads a value and resets its expiration time.

func (*RouteTable) Set added in v0.0.7

func (r *RouteTable) Set(ctx context.Context, key, val string, expire time.Duration) error

Set stores a key-value pair in Redis with an expiration time.

func (*RouteTable) SetNx added in v0.0.7

func (r *RouteTable) SetNx(ctx context.Context, key, val string, expire time.Duration) (bool, string, error)

SetNx sets a key-value pair only if the key does not exist.

Jump to

Keyboard shortcuts

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