Skip to content

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

License

Notifications You must be signed in to change notification settings

SevereCloud/persistent-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

persistent-cache

Build Status Go Report Card Documentation codecov GitHub issues license

go-cache is an in-memory key:value store/cache similar to memcached that issuitable for applications running on a single machine. Its major advantage is that, being essentially a thread-safe map[string]interface{} with expiration times, it doesn't need to serialize or transmit its contents over the network.

Any object can be stored, for a given duration or forever, and the cache can be safely used by multiple goroutines.

persistent-cache write cache changes to the binlog file.

Installation

go get github.com/severecloud/persistent-cache

Usage

package main

import (
	"fmt"

	pcache "github.com/severecloud/persistent-cache"
)

func main() {
	c, err := pcache.Load(pcache.NoExpiration, 0, "test")
	if err != nil {
		c, err = pcache.New(pcache.NoExpiration, 0, "test")
		if err != nil {
			panic(err)
		}
	}

	foo, found := c.Get("foo")
	if found {
		fmt.Println(foo)
	}

	c.SetDefault("foo", "bar")
}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 8

Languages