Install: go get github.com/cookingkode/dmap
// Prep the configconf:=&dmap.Config{
[]string{"localhost:6379", "localhost:7777"}, // your redis hosts
[]int{0, 0}, // DBs of each of the redis hosts32, // local shards : function of how much concurreny is there in the app"test", // Dmap name , used as a namespace for backendtrue, // Want 2Q based LRU?4, // Valid if LRU, no of items in the LRU cache
}
//init // the instance returned is a thread-safe string-> interface{} map// values set in other instances are reflected heredmap:=dmap.New(conf)
// Set without expirydmap.Set("Name", "Cooker", 0)
whatIsMyName : =dmap.Get("Name")
// Set with expiry of 2 sdmap.Set("Foo", "Bar", 2)
// Values are interface and so can change typesdmap.Set("x", 1)
dmap.Set("x", "astring")
- see tests/test.go for an interactive shell to test normal map
- see tests/test_lru.go for an interactive shell to test LRU map
- TODO : automated tests