rstore

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 4 Imported by: 0

README

Fiber Cache Redis Integration

This package lets You use redis as Your cache with fiber.v2 (golang web framework)

Usage

TODO: finish this section

Example

TODO: full example of usage

Testing

To run integration tests please start redis on localhost:6379 either via docker or on your own box. This is an integration package so it doesnt make much sense to mock redis.

You run tests by doing

make test

To run benchmarks just do:

make bench

Ofc because we dont use mock it will be heavily influenced by your redis performance. But at least You can compare to fiber.Memory and more less figure out/guess the impact.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...RedisClientOption) fiber.Storage

New returns fiber.Storage implementation only

Types

type RedisClientOption

type RedisClientOption func(*RedisStorage)

func WithAddr

func WithAddr(addr string) RedisClientOption

WithAddr sets address of redis

func WithClient

func WithClient(client *redis.Client) RedisClientOption

Withclient sets entirely dev owned Client, all other options will be discarded if this is in use

func WithDB

func WithDB(DB int) RedisClientOption

WithDB sets DB number

func WithPassword

func WithPassword(password string) RedisClientOption

WithPassword sets password for default redis client

type RedisStorage

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

RedisStorage holds client info and implements fiber.Storage interface

func NewClient

func NewClient(opts ...RedisClientOption) *RedisStorage

Newclient returns fiber.Storage plus extra methods

func (*RedisStorage) Client

func (rs *RedisStorage) Client() *redis.Client

Client returns redis client pointer directly for extra setup?

func (*RedisStorage) Close

func (rs *RedisStorage) Close() error

Close closes the storage and will stop any running garbage collectors and open connections.

func (*RedisStorage) Delete

func (rs *RedisStorage) Delete(key string) error

Delete deletes the value for the given key. It returns no error if the storage does not contain the key,

func (*RedisStorage) Get

func (rs *RedisStorage) Get(key string) ([]byte, error)

Get gets the value for the given key. It returns ErrNotFound if the storage does not contain the key.

func (*RedisStorage) Reset

func (rs *RedisStorage) Reset() error

Reset resets the storage and delete all keys.

func (*RedisStorage) Set

func (rs *RedisStorage) Set(key string, val []byte, ttl time.Duration) error

Set stores the given value for the given key along with a time-to-live expiration value, 0 means live for ever Empty key or value will be ignored without an error.

Jump to

Keyboard shortcuts

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