Documentation
¶
Overview ¶
Identity Directory implementation with tiered caching, using Redis.
Index ¶
- type RedisDirectory
- func (d *RedisDirectory) Lookup(ctx context.Context, a syntax.AtIdentifier) (*identity.Identity, error)
- func (d *RedisDirectory) LookupDID(ctx context.Context, did syntax.DID) (*identity.Identity, error)
- func (d *RedisDirectory) LookupDIDWithCacheState(ctx context.Context, did syntax.DID) (*identity.Identity, bool, error)
- func (d *RedisDirectory) LookupHandle(ctx context.Context, h syntax.Handle) (*identity.Identity, error)
- func (d *RedisDirectory) LookupHandleWithCacheState(ctx context.Context, h syntax.Handle) (*identity.Identity, bool, error)
- func (d *RedisDirectory) Purge(ctx context.Context, a syntax.AtIdentifier) error
- func (d *RedisDirectory) ResolveHandle(ctx context.Context, h syntax.Handle) (syntax.DID, error)
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 (d *RedisDirectory) Lookup(ctx context.Context, a syntax.AtIdentifier) (*identity.Identity, error)
func (*RedisDirectory) LookupDIDWithCacheState ¶
func (*RedisDirectory) LookupHandle ¶
func (*RedisDirectory) LookupHandleWithCacheState ¶
func (*RedisDirectory) Purge ¶
func (d *RedisDirectory) Purge(ctx context.Context, a syntax.AtIdentifier) error