Skip to content

mdaliyan/icache

 
 

Repository files navigation

icache

Build Status Coverage Status Go Report Card Go Walker godoc License

icache is a cache library for Go with high concurrent access performance. Its major advantages over the other libraries is that it doesn't serialize your data and only stores values. As the result you won't need to unmarshal anything when you get the values from it. This saves you time and resources.

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

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

Installation

go get github.com/mdaliyan/icache

Usage

// make na new Pot with the default expiration time of 1 Hour
// set ttl to 0 to disable expiration entirely
var pot = icache.NewPot(time.Hour) 


var U = user{
    ID:   "foo",
    Name: "John Doe",
    Age:  30,
}

// set user to "foo" key
pot.Set("foo", U)


// get the user previously set to "foo" key into u2 
var u2 user
err = pot.Get("foo", &u2)


// if you pass a mismatched type you simply get a "type mismatch" error
var u3 string
err = pot.Get("foo", &u3)

// you also can add tags to your entries
pot.Set("foo", U, "tag1", "tag2")
pot.Set("faa", U, "tag1")
pot.Set("fom", U, "tag3")

// and delete multiple entries at once
pot.DropTags("tag1")

I might add MGet method later

About

A High Performance, Generic, thread-safe, zero-dependency, key-value, in-memory cache

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages