Golang Cache component - Multiple drivers

Cachego

Codecov branch GoDoc Go Report Card License

Simple interface for caching

Installation

Cachego requires Go 1.13 or later.

go get github.com/faabiosr/cachego

Usage

package main

import (
	"log"
	"time"

	"github.com/faabiosr/cachego/sync"
)

func main() {
	cache := sync.New()

	if err := cache.Save("user_id", "1", 10*time.Second); err != nil {
		log.Fatal(err)
	}

	id, err := cache.Fetch("user_id")
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("user id: %s \n", id)

	keys := cache.FetchMulti([]string{"user_id", "user_name"})

	for k, v := range keys {
		log.Printf("%s: %s\n", k, v)
	}

	if cache.Contains("user_name") {
		cache.Delete("user_name")
	}

	if _, err := cache.Fetch("user_name"); err != nil {
		log.Printf("%v\n", err)
	}

	if err := cache.Flush(); err != nil {
		log.Fatal(err)
	}
}

Supported drivers

Documentation

Read the full documentation at https://pkg.go.dev/github.com/faabiosr/cachego.

Development

Requirements

Makefile

// Clean up
$ make clean

//Run tests and generates html coverage file
$ make cover

// Up the docker containers for testing
$ make docker

// Format all go files
$ make fmt

//Run linters
$ make lint

// Run tests
$ make test

License

This project is released under the MIT licence. See LICENSE for more details.

Owner
Fabio Ribeiro
Software Artisan
Fabio Ribeiro
Similar Resources

Continuous Benchmark for cache libraries written in golang.

Simple performance comparison of cache libraries written in golang. Reports Continuous Bencmark Result (click here) Default parameters 256 shards * 32

Oct 26, 2022

A File Cache With Golang

A File Cache With Golang

Nov 13, 2022

Gocodecache - An in-memory cache library for code value master in Golang

gocodecache An in-memory cache library for code master in Golang. Installation g

Jun 23, 2022

LevelDB style LRU cache for Go, support non GC object.

Go语言QQ群: 102319854, 1055927514 凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa LRU Cache Install go get github.com/chai2010/c

Jul 5, 2020

groupcache is a caching and cache-filling library, intended as a replacement for memcached in many cases.

groupcache Summary groupcache is a distributed caching and cache-filling library, intended as a replacement for a pool of memcached nodes in many case

Dec 31, 2022

fastcache - fast thread-safe inmemory cache for big number of entries in Go

Fast thread-safe inmemory cache for big number of entries in Go. Minimizes GC overhead

Dec 27, 2022

Efficient cache for gigabytes of data written in Go.

BigCache Fast, concurrent, evicting in-memory cache written to keep big number of entries without impact on performance. BigCache keeps entries on hea

Dec 30, 2022

An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.

go-cache go-cache is an in-memory key:value store/cache similar to memcached that is suitable for applications running on a single machine. Its major

Dec 29, 2022
Comments
  • Solving implicit assignment of unexported field issue in cachego.Mongo

    Solving implicit assignment of unexported field issue in cachego.Mongo

    I was receiving the following error when trying to use the Mongo cache (as documented):

    implicit assignment of unexported field 'collection' in cachego.Mongo literal

    For me, exporting Mongo.Collection fixed this issue.

    Please note, this issue may affect other cache drivers as well, but I did not test those.

  • Add support for official mongodb driver

    Add support for official mongodb driver

    Closes #10

    Changes

    • added a new package mongoo : Mongo Official as the cachego already has mongo package.
    • added test for mongoo_test

    Tests

    • tested make test
  • Support files

    Support files

    • Add golang dep for downloading test dependencies
    • Create a makefile for supporting test and test-coverage
    • Update documentation with new development features
    • Update travis file to download and install golang dep
    • Drop support for GO 1.5 to 1.7
Dec 28, 2022
Package cache is a middleware that provides the cache management for Flamego.

cache Package cache is a middleware that provides the cache management for Flamego. Installation The minimum requirement of Go is 1.16. go get github.

Nov 9, 2022
A mem cache base on other populator cache, add following feacture

memcache a mem cache base on other populator cache, add following feacture add lazy load(using expired data, and load it asynchronous) add singlefligh

Oct 28, 2021
Cache - A simple cache implementation

Cache A simple cache implementation LRU Cache An in memory cache implementation

Jan 25, 2022
An in-memory cache library for golang. It supports multiple eviction policies: LRU, LFU, ARC

GCache Cache library for golang. It supports expirable Cache, LFU, LRU and ARC. Features Supports expirable Cache, LFU, LRU and ARC. Goroutine safe. S

May 31, 2021
☔️ A complete Go cache library that brings you multiple ways of managing your caches
☔️ A complete Go cache library that brings you multiple ways of managing your caches

Gocache Guess what is Gocache? a Go cache library. This is an extendable cache library that brings you a lot of features for caching data. Overview He

Jan 1, 2023
gdcache is a pure non-intrusive distributed cache library implemented by golang
gdcache is a pure non-intrusive distributed cache library implemented by golang

gdcache is a pure non-intrusive distributed cache library implemented by golang, you can use it to implement your own distributed cache

Sep 26, 2022
Cache list, count with filter param golang, using struct, hashkey

Dumbcache Cache list, count with filter param golang, using struct, hashkey Structure we hash your request object to md5 hashing and add a prefix coun

Nov 1, 2021
Fast key-value cache written on pure golang

GoCache Simple in-memory key-value cache with default or specific expiration time. Install go get github.com/DylanMrr/GoCache Features Key-value stor

Nov 16, 2021
Light weight thread safe cache for golang

go-cache Light weight thread safe LRU cache Getting started import( "fmt" "github.com/tak1827/go-cache/lru" ) func main() { size := 2 cache := l

Dec 12, 2021