Back to

Package cachego

Latest Go to latest

The highest tagged major version is .

Published: Sep 7, 2020 | License: MIT | Module:


Package cachego provides a simple way to use cache drivers.

Example Usage

The following is a simple example using memcached driver:

import (

func main() {

  cache := cachego.NewMemcached(

  cache.Save("foo", "bar")




const (
	// ErrCacheExpired returns an error when the cache key was expired.
	ErrCacheExpired = err("cache expired")

	// ErrFlush returns an error when flush fails.
	ErrFlush = err("unable to flush")

	// ErrSave returns an error when save fails.
	ErrSave = err("unable to save")

	// ErrDelete returns an error when deletion fails.
	ErrDelete = err("unable to delete")

	// ErrDecode returns an errors when decode fails.
	ErrDecode = err("unable to decode")

type Cache

type Cache interface {

	// Contains check if a cached key exists
	Contains(key string) bool

	// Delete remove the cached key
	Delete(key string) error

	// Fetch retrieve the cached key value
	Fetch(key string) (string, error)

	// FetchMulti retrieve multiple cached keys value
	FetchMulti(keys []string) map[string]string

	// Flush remove all cached keys
	Flush() error

	// Save cache a value by key
	Save(key string, value string, lifeTime time.Duration) error

Cache is the top-level cache interface

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier