cache

package
v0.0.0-...-c5d5a31 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache provides simple caching mechanisms

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotSetKey = errors.New("unable to set key")

ErrCannotSetKey indicates an issue setting the key

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	Get(key string) (interface{}, error)
	Put(key string, value interface{}, ttl time.Duration) error
}

Cacher outlines the methods for our cache

type Redis

type Redis struct {
	RedisPool *redis.Pool
	Prefix    string
}

Redis implements the Cacher interface

func (*Redis) Get

func (r *Redis) Get(key string) (interface{}, error)

Get retrieves an item from redis

func (*Redis) Put

func (r *Redis) Put(key string, value interface{}, ttl time.Duration) error

Put sets a redis key to value

type Simple

type Simple struct {
	M map[string]Value
}

Simple implements the Cacher interface

func (*Simple) Get

func (s *Simple) Get(key string) (interface{}, error)

Get retrieves an item from redis

func (*Simple) Put

func (s *Simple) Put(key string, val interface{}, ttl time.Duration) error

Put sets a redis key to value

type Value

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

Value is a value with an expiration

Jump to

Keyboard shortcuts

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