redisdir

package
v0.0.0-...-adf259e Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Overview

Identity Directory implementation with tiered caching, using Redis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisDirectory

type RedisDirectory struct {
	Inner            identity.Directory
	ErrTTL           time.Duration
	HitTTL           time.Duration
	InvalidHandleTTL time.Duration
	// contains filtered or unexported fields
}

Uses redis as a cache for identity lookups.

Includes an in-process LRU cache as well (provided by the redis client library), for hot key (identities).

func NewRedisDirectory

func NewRedisDirectory(inner identity.Directory, redisURL string, hitTTL, errTTL, invalidHandleTTL time.Duration, lruSize int) (*RedisDirectory, error)

Creates a new caching `identity.Directory` wrapper around an existing directory, using Redis and in-process LRU for caching.

`redisURL` contains all the redis connection config options. `hitTTL` and `errTTL` define how long successful and errored identity metadata should be cached (respectively). errTTL is expected to be shorted than hitTTL. `lruSize` is the size of the in-process cache, for each of the handle and identity caches. 10000 is a reasonable default.

NOTE: Errors returned may be inconsistent with the base directory, or between calls. This is because cached errors are serialized/deserialized and that may break equality checks.

func (*RedisDirectory) Lookup

func (*RedisDirectory) LookupDID

func (d *RedisDirectory) LookupDID(ctx context.Context, did syntax.DID) (*identity.Identity, error)

func (*RedisDirectory) LookupDIDWithCacheState

func (d *RedisDirectory) LookupDIDWithCacheState(ctx context.Context, did syntax.DID) (*identity.Identity, bool, error)

func (*RedisDirectory) LookupHandle

func (d *RedisDirectory) LookupHandle(ctx context.Context, h syntax.Handle) (*identity.Identity, error)

func (*RedisDirectory) LookupHandleWithCacheState

func (d *RedisDirectory) LookupHandleWithCacheState(ctx context.Context, h syntax.Handle) (*identity.Identity, bool, error)

func (*RedisDirectory) Purge

func (*RedisDirectory) ResolveHandle

func (d *RedisDirectory) ResolveHandle(ctx context.Context, h syntax.Handle) (syntax.DID, error)

Jump to

Keyboard shortcuts

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