cache

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(context.Context, string) (bool, bool, error)
	Set(context.Context, string, bool) error
}

Cache is an interface for caching ip addresses

type MemoryCache

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

MemoryCache is used to store/fetch ip proximity from an in-memory cache.

func NewMemoryCache

func NewMemoryCache(memoryOptions *MemoryOptions) *MemoryCache

NewRedisCache provides a new in-memory cache client.

func (*MemoryCache) Get

func (m *MemoryCache) Get(ctx context.Context, key string) (bool, bool, error)

Get gets value from the in-memory cache.

func (*MemoryCache) Set

func (m *MemoryCache) Set(ctx context.Context, key string, value bool) error

Set sets k/v in the in-memory cache.

type MemoryOptions

type MemoryOptions struct {
	TTL time.Duration
}

MemoryOptions holds in-memory cache configuration parameters.

type RedisCache

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

RedisCache is used to store/fetch ip proximity from redis.

func NewRedisCache

func NewRedisCache(redisOpts *RedisOptions) *RedisCache

NewRedisCache provides a new redis cache client.

func (*RedisCache) Get

func (r *RedisCache) Get(ctx context.Context, key string) (bool, bool, error)

Get gets value from redis.

func (*RedisCache) Set

func (r *RedisCache) Set(ctx context.Context, key string, value bool) error

Set sets k/v in redis.

type RedisOptions

type RedisOptions struct {
	Addr     string
	Username string
	Password string
	DB       int
	TTL      time.Duration
}

RedisOptions holds redis configuration parameters.

Jump to

Keyboard shortcuts

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