node.go 530 B

12345678910111213141516171819202122232425262728
  1. package cache
  2. import (
  3. "time"
  4. "github.com/uozi-tech/cosy/logger"
  5. )
  6. const (
  7. NodeCacheKey = "enabled_nodes"
  8. NodeCacheTTL = 10 * time.Minute
  9. )
  10. // InvalidateNodeCache removes the node cache entry
  11. func InvalidateNodeCache() {
  12. Del(NodeCacheKey)
  13. logger.Debug("Invalidated node cache")
  14. }
  15. // GetCachedNodes retrieves nodes from cache
  16. func GetCachedNodes() (interface{}, bool) {
  17. return Get(NodeCacheKey)
  18. }
  19. // SetCachedNodes stores nodes in cache
  20. func SetCachedNodes(data interface{}) {
  21. Set(NodeCacheKey, data, NodeCacheTTL)
  22. }