redis

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultExpire = time.Hour

DefaultExpire is the expire time we set on Redis when Set/SetExpiration are called with expire=true

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Get(context.Context, string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd
	Persist(ctx context.Context, key string) *redis.BoolCmd
}

Client is a subset of functions from the golang redis client that we need to implement our cache

type ContentClaimsStore

type ContentClaimsStore = Store[cid.Cid, delegation.Delegation]

ContentClaimsStore is a RedisStore for storing content claims that implements types.ContentClaimsStore

func NewContentClaimsStore

func NewContentClaimsStore(client Client) *ContentClaimsStore

NewContentClaimsStore returns a new instance of a Content Claims Store using the given redis client

type ProviderStore

type ProviderStore = Store[multihash.Multihash, []model.ProviderResult]

ProviderStore is a RedisStore for storing IPNI data that implements types.ProviderStore

func NewProviderStore

func NewProviderStore(client Client) *ProviderStore

NewProviderStore returns a new instance of an IPNI store using the given redis client

type ShardedDagIndexStore

type ShardedDagIndexStore = Store[types.EncodedContextID, blobindex.ShardedDagIndexView]

ShardedDagIndexStore is a RedisStore for storing sharded dag indexes that implements types.ShardedDagIndexStore

func NewShardedDagIndexStore

func NewShardedDagIndexStore(client Client) *ShardedDagIndexStore

NewShardedDagIndexStore returns a new instance of a ShardedDagIndex store using the given redis client

type Store

type Store[Key, Value any] struct {
	// contains filtered or unexported fields
}

Store wraps the go redis client to implement our general purpose cache interface, using the providedserialization/deserialization functions

func NewStore

func NewStore[Key, Value any](
	fromRedis func(string) (Value, error),
	toRedis func(Value) (string, error),
	keyString func(Key) string,
	client Client) *Store[Key, Value]

NewStore returns a new instance of a redis store with the provided serialization/deserialization functions

func (*Store[Key, Value]) Get

func (rs *Store[Key, Value]) Get(ctx context.Context, key Key) (Value, error)

Get returns deserialized values from redis

func (*Store[Key, Value]) Set

func (rs *Store[Key, Value]) Set(ctx context.Context, key Key, value Value, expires bool) error

Set saves a serialized value to redis

func (*Store[Key, Value]) SetExpirable

func (rs *Store[Key, Value]) SetExpirable(ctx context.Context, key Key, expires bool) error

SetExpirable changes the expiration property for a given key

Jump to

Keyboard shortcuts

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