mem.go 398 B

123456789101112131415161718192021222324252627
  1. package cache
  2. /*
  3. var (
  4. cache sync.Map
  5. )
  6. // Get key from cache
  7. func Get(key interface{}) (interface{}, bool) {
  8. return cache.Load(key)
  9. }
  10. // Set key-value to cache
  11. func Set(key, value interface{}) {
  12. cache.Store(key, value)
  13. }
  14. // Del delete key from cache
  15. func Del(key interface{}) {
  16. cache.Delete(key)
  17. }
  18. // Range list cache
  19. func Range(cb func(k, v interface{}) bool) {
  20. cache.Range(cb)
  21. }
  22. // */