Documentation
¶
Index ¶
- Constants
- Variables
- type BatchingValueSetStore
- func (bvs *BatchingValueSetStore[K, V]) Add(ctx context.Context, key K, values ...V) (uint64, error)
- func (bvs *BatchingValueSetStore[K, V]) Batch() types.ValueSetCacheBatcher[K, V]
- func (bvs *BatchingValueSetStore[K, V]) Members(ctx context.Context, key K) ([]V, error)
- func (bvs *BatchingValueSetStore[K, V]) SetExpirable(ctx context.Context, key K, expires bool) error
- type Client
- type ContentClaimsStore
- type NoProviderStore
- type Option
- type PipelineBatcher
- type PipelineClient
- type Pipelineable
- type Pipeliner
- type ProviderStore
- type ShardedDagIndexStore
- type Store
- func (rs *Store[Key, Value]) Add(ctx context.Context, key Key, values ...Value) (uint64, error)
- func (rs *Store[Key, Value]) Get(ctx context.Context, key Key) (Value, error)
- func (rs *Store[Key, Value]) Members(ctx context.Context, key Key) ([]Value, error)
- func (rs *Store[Key, Value]) Set(ctx context.Context, key Key, value Value, expires bool) error
- func (rs *Store[Key, Value]) SetExpirable(ctx context.Context, key Key, expires bool) error
Constants ¶
const DefaultExpire = time.Hour
DefaultExpire is the expire time we set on Redis when Set/SetExpiration are called with expire=true
Variables ¶
var ErrDecodingMulticodec = errors.New("error parsing multicodec")
Functions ¶
This section is empty.
Types ¶
type BatchingValueSetStore ¶ added in v1.8.0
type BatchingValueSetStore[K, V any] struct { // contains filtered or unexported fields }
func NewBatchingValueSetStore ¶ added in v1.8.0
func NewBatchingValueSetStore[K, V any]( fromRedis func(string) (V, error), toRedis func(V) (string, error), keyString func(K) string, client PipelineClient, opts ...Option, ) *BatchingValueSetStore[K, V]
NewBatchingValueSetStore creates a new value-set store (a store whose values are sets) that allows batching.
func (*BatchingValueSetStore[K, V]) Add ¶ added in v1.8.0
func (bvs *BatchingValueSetStore[K, V]) Add(ctx context.Context, key K, values ...V) (uint64, error)
func (*BatchingValueSetStore[K, V]) Batch ¶ added in v1.8.0
func (bvs *BatchingValueSetStore[K, V]) Batch() types.ValueSetCacheBatcher[K, V]
func (*BatchingValueSetStore[K, V]) Members ¶ added in v1.8.0
func (bvs *BatchingValueSetStore[K, V]) Members(ctx context.Context, key K) ([]V, error)
func (*BatchingValueSetStore[K, V]) SetExpirable ¶ added in v1.8.0
func (bvs *BatchingValueSetStore[K, V]) SetExpirable(ctx context.Context, key K, expires bool) error
type Client ¶
type Client interface { Get(context.Context, string) *redis.StringCmd Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd SAdd(ctx context.Context, key string, members ...interface{}) *redis.IntCmd SMembers(ctx context.Context, key string) *redis.StringSliceCmd 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, opts ...Option) *ContentClaimsStore
NewContentClaimsStore returns a new instance of a Content Claims Store using the given redis client
type NoProviderStore ¶ added in v1.6.8
NoProviderStore is a RedisStore for storing IPNI data that implements types.ProviderStore
func NewNoProviderStore ¶ added in v1.6.8
func NewNoProviderStore(client Client, opts ...Option) *NoProviderStore
NewNoProviderStore returns a new instance of an IPNI store using the given redis client
type PipelineBatcher ¶ added in v1.8.0
type PipelineBatcher[K, V any] struct { // contains filtered or unexported fields }
func NewPipelineBatcher ¶ added in v1.8.0
func (*PipelineBatcher[K, V]) Add ¶ added in v1.8.0
func (pb *PipelineBatcher[K, V]) Add(ctx context.Context, key K, values ...V) error
func (*PipelineBatcher[K, V]) Commit ¶ added in v1.8.0
func (pb *PipelineBatcher[K, V]) Commit(ctx context.Context) error
func (*PipelineBatcher[K, V]) SetExpirable ¶ added in v1.8.0
func (pb *PipelineBatcher[K, V]) SetExpirable(ctx context.Context, key K, expires bool) error
type PipelineClient ¶ added in v1.8.0
type PipelineClient interface { Client Pipelineable }
PipelineClient is a client that also supports pipelining.
func NewClientAdapter ¶ added in v1.8.0
func NewClientAdapter(client *redis.Client) PipelineClient
NewClientAdapter converts a redis.Client into a PipelineClient.
func NewClusterClientAdapter ¶ added in v1.8.0
func NewClusterClientAdapter(client *redis.ClusterClient) PipelineClient
NewClientAdapter converts a redis.ClusterClient into a PipelineClient.
type Pipelineable ¶ added in v1.8.0
type Pipelineable interface {
Pipeline() Pipeliner
}
Pipelineable allows pipelines to be created for batching of write commands.
type Pipeliner ¶ added in v1.8.0
type Pipeliner interface { SAdd(ctx context.Context, key string, members ...any) *redis.IntCmd Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd Persist(ctx context.Context, key string) *redis.BoolCmd Exec(ctx context.Context) ([]redis.Cmder, error) }
Pipeliner is a subset of functions from redis.Pipeliner that we need to implement pipelining for our cache.
type ProviderStore ¶
type ProviderStore = BatchingValueSetStore[multihash.Multihash, model.ProviderResult]
ProviderStore is a RedisStore for storing IPNI data that implements types.ProviderStore
func NewProviderStore ¶
func NewProviderStore(client PipelineClient, opts ...Option) *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, opts ...Option) *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, opts ...Option) *Store[Key, Value]
NewStore returns a new instance of a redis store with the provided serialization/deserialization functions
func (*Store[Key, Value]) Add ¶ added in v1.2.1
Add another value to the set of values for the given key.
func (*Store[Key, Value]) Members ¶ added in v1.2.1
Members returns all deserialized set values from redis. If the key does not exist, it returns ErrKeyNotFound.