cache

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("Cache miss")

Functions

This section is empty.

Types

type Cache

type Cache interface {
	GetTranslation(ctx context.Context, projectID int, languageCode, format string) (item *CacheItem, err error)
	SetTranslation(ctx context.Context, projectID int, languageCode, format string, data []byte) (checksum string, err error)
	PurgeTranslation(ctx context.Context, projectID int, languageCode string) (err error)
	PurgeProject(ctx context.Context, projectID int) (err error)
	GetTTL() time.Duration
	PingContext(ctx context.Context) error
}

type CacheItem added in v0.1.1

type CacheItem struct {
	CreatedAt time.Time
	Checksum  string
	Data      []byte
}

type FilesystemCache

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

func NewFilesystemCache

func NewFilesystemCache(cacheDir string, ttl time.Duration) (*FilesystemCache, error)

func (*FilesystemCache) GetTTL added in v0.1.1

func (f *FilesystemCache) GetTTL() time.Duration

func (*FilesystemCache) GetTranslation

func (f *FilesystemCache) GetTranslation(ctx context.Context, projectID int, languageCode, format string) (*CacheItem, error)

func (*FilesystemCache) PingContext added in v0.4.0

func (f *FilesystemCache) PingContext(ctx context.Context) error

func (*FilesystemCache) PurgeProject

func (f *FilesystemCache) PurgeProject(ctx context.Context, projectID int) error

func (*FilesystemCache) PurgeTranslation

func (f *FilesystemCache) PurgeTranslation(ctx context.Context, projectID int, languageCode string) error

func (*FilesystemCache) SetTranslation

func (f *FilesystemCache) SetTranslation(ctx context.Context, projectID int, languageCode, format string, data []byte) (string, error)

type RedisCache

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

func NewRedisCache

func NewRedisCache(c *redis.Client, ttl time.Duration) *RedisCache

func (*RedisCache) GetTTL added in v0.1.1

func (r *RedisCache) GetTTL() time.Duration

func (*RedisCache) GetTranslation

func (r *RedisCache) GetTranslation(ctx context.Context, projectID int, languageCode, format string) (*CacheItem, error)

func (*RedisCache) PingContext added in v0.4.0

func (r *RedisCache) PingContext(ctx context.Context) error

func (*RedisCache) PurgeProject

func (r *RedisCache) PurgeProject(ctx context.Context, projectID int) error

func (*RedisCache) PurgeTranslation

func (r *RedisCache) PurgeTranslation(ctx context.Context, projectID int, languageCode string) error

func (*RedisCache) SetTranslation

func (r *RedisCache) SetTranslation(ctx context.Context, projectID int, languageCode, format string, data []byte) (string, error)

type RedisCacheItem

type RedisCacheItem struct {
	CreatedAt time.Time
	Checksum  string
	Data      []byte
}

type RedisLogger added in v0.1.1

type RedisLogger struct {
	*logrus.Entry
}

func (*RedisLogger) Printf added in v0.1.1

func (r *RedisLogger) Printf(ctx context.Context, format string, v ...interface{})

Jump to

Keyboard shortcuts

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