cache

package
v0.0.0-...-e9492ee Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package cache provide caching systems for images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tokenize

func Tokenize(req *http.Request) (string, error)

Tokenize generate unique key for request caching strategy.

Types

type Cache

type Cache interface {
	Get(key string) ([]byte, error)
	Set(key string, val []byte, expiry time.Duration) error
}

Cache Define cache system interface.

func New

func New(conf config.Config) (Cache, error)

New is the cache factory to instantiate a new instance of cache.

type MemoryCache

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

MemoryCache in-memory cache system struct.

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) ([]byte, error)

Get return cached image with given key.

func (*MemoryCache) Set

func (c *MemoryCache) Set(key string, v []byte, expiry time.Duration) error

Set add a value into in-memory with custom expiry.

type NoneCache

type NoneCache struct{}

NoneCache dummy cache system.

func (*NoneCache) Get

func (c *NoneCache) Get(key string) ([]byte, error)

Get always return nil with not found error.

func (*NoneCache) Set

func (c *NoneCache) Set(_ string, _ []byte, _ time.Duration) error

Set always return nil.

type RedisCache

type RedisCache struct{} // client *redis.Client

RedisCache hold redis client.

func (*RedisCache) Get

func (c *RedisCache) Get(key string) ([]byte, error)

Get return cached media with given key from redis.

func (*RedisCache) Set

func (c *RedisCache) Set(key string, v []byte, expiry time.Duration) error

Set add a new image in cache with custom expiry.

Jump to

Keyboard shortcuts

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