cache

package module
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

README

Cache

Installation

$ go get bitbucket.org/amotus/cache

Usage

Each implementation package contains a New function to obtain a new instance of the implementation.

Unit tests

A mocked implementation of the cache interface is auto-generated and kept updated every release.
Simply use the mocked interface in your unit tests.

Redis

Use the Config struct to configure the Redis wrapper and the New function to instantiate.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get returns the value associated with the provided key, if any, and a boolean value representing if a value was associated with the key.
	Get(key string) (string, bool, error)

	// Remember stores a value and associates it to a key for X seconds after which it expires.
	Remember(key string, value interface{}, duration time.Duration) error

	// Forget removes the key-value pair.
	Forget(key string) error

	// Increment increments the value of a key by 1.
	Increment(key string) (int64, error)

	// Expire sets the expiration time for a key.
	Expire(key string, duration time.Duration) error

	// ForgetAll removes all key-value that match the given pattern
	ForgetAll(keyPattern string) (int, error)

	// Keys get all keys match given pattern
	Keys(keyPattern string) ([]string, error)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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