FAQ
Hi, everyone.

Announcing a multifunction cache library for golang.

http://github.com/bluele/gcache

# Features

    - Supports expirable Cache, LFU, LRU and ARC.
    - Goroutine safe.
    - Supports event handlers which evict and add entry. (Optional)
    - Automatically load cache if it doesn't exists. (Optional)

# Automatically load value

package main

import (
   "github.com/bluele/gcache"
   "fmt"
)

func main() {
   gc := gcache.New(20).
     LRU().
     LoaderFunc(func(key interface{}) (interface{}, error) {
       return "ok", nil
     }).
     Build()
   value, err := gc.Get("key")
   if err != nil {
     panic(err)
   }
   fmt.Println("Get:", value)
}

// output
Get: ok

# Manually set a key-value pair.

package main

import (
   "github.com/bluele/gcache"
   "fmt"
)

func main() {
   gc := gcache.New(20).
     LRU().
     Build()
   gc.Set("key", "ok")
   value, err := gc.Get("key")
   if err != nil {
     panic(err)
   }
   fmt.Println("Get:", value)
}

// output
Get: ok

Please check https://github.com/bluele/gcache if you like it.

I'll be glad if you try to use it.

- Jun

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 11, '15 at 4:28p
activeFeb 11, '15 at 7:13p
posts2
users2
websitegolang.org

2 users in discussion

Damian Gryski: 1 post Jun Kimura: 1 post

People

Translate

site design / logo © 2022 Grokbase