cached

package
v0.0.0-...-f68f6f9 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Add(ctx context.Context, key string, value urlresolver.Result)
	Get(ctx context.Context, key string) (value urlresolver.Result, ok bool)
	Name() string
}

Cache is a generic cache interface.

type RedisCache

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

RedisCache caches results in redis.

func NewRedisCache

func NewRedisCache(cache *cache.Cache, ttl time.Duration) *RedisCache

NewRedisCache creates a new RedisCache whose entries will expire after the given TTL.

func (*RedisCache) Add

func (c *RedisCache) Add(ctx context.Context, key string, value urlresolver.Result)

Add adds a Result to the cache.

func (*RedisCache) Get

func (c *RedisCache) Get(ctx context.Context, key string) (urlresolver.Result, bool)

Get gets a Result from the cache, returning a bool indicating whether it was present.

func (*RedisCache) Name

func (c *RedisCache) Name() string

Name returns the name of the cache, for instrumentation purposes.

type Resolver

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

Resolver is a Resolver implementation that caches its results.

func NewResolver

func NewResolver(resolver urlresolver.Interface, cache Cache) *Resolver

NewResolver creates a new cached Resolver.

func (*Resolver) Resolve

func (c *Resolver) Resolve(ctx context.Context, url string) (urlresolver.Result, error)

Resolve resolves a URL if it is not already cached.

Jump to

Keyboard shortcuts

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