c := simplecache.New(1)
if !c.SetMaxMemory("2MB") {
log.Panicln("Set max memory for cache failed")
}
for i := 0; i < 1000; i++ {
err := c.Set(fmt.Sprintf("key%d", i), fmt.Sprintf("val%d", i), time.Second)
if err != nil {
log.Panicln(err)
}
}
v, ok := c.Get(fmt.Sprintf("key%d", 1))
if !ok {
log.Panicln("Not found")
}
log.Println("Found", v.(string))
c.Del(fmt.Sprintf("key%d", 1))
log.Println("keys ", c.Keys())
log.Println("keys len", c.Size())
c.Flush()
time.Sleep(time.Second * 2) // for GC
-
Notifications
You must be signed in to change notification settings - Fork 0
FlowerWrong/simplecache
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
simple cache library in go
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published