项目作者: nuczzz

项目描述 :
File cache with LRU algorithm, contains memory cache and disk cache.
高级语言: Go
项目地址: git://github.com/nuczzz/fcache.git
创建时间: 2019-01-03T08:28:16Z
项目社区:https://github.com/nuczzz/fcache

开源协议:

下载


Fcache

File cache with LRU algorithm, contains memory cache and disk cache.

Example

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/nuczzz/fcache"
  5. )
  6. func main() {
  7. memCache := fcache.NewMemCache(10, false)
  8. memCache.Set("key1", []byte("123456789"))
  9. memCache.Set("key2", []byte("0"))
  10. memCache.Set("key3", []byte("1"))
  11. fmt.Println(memCache.Get("key3"))
  12. fmt.Println(memCache.Get("key1"))
  13. hit, total := memCache.GetHitInfo()
  14. fmt.Printf("hit: %v, total: %v\n", hit, total)
  15. diskCache := fcache.NewDiskCache(10, false, "./cache")
  16. diskCache.Set("key1", []byte("123456789"))
  17. diskCache.Set("key2", []byte("0"))
  18. diskCache.Set("key3", []byte("1"))
  19. fmt.Println(diskCache.Get("key3"))
  20. hit, total = diskCache.GetHitInfo()
  21. fmt.Printf("hit: %v, total: %v\n", hit, total)
  22. }