Guest User

Untitled

a guest
Oct 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. (defrecord BasicWelleCache [^String bucket ^String content-type ^Integer w])
  2.  
  3. (extend-protocol cache/CacheProtocol
  4. BasicWelleCache
  5. (lookup [c k]
  6. (:value (kv/fetch-one (.bucket c) k)))
  7. (has? [c k]
  8. (not (empty? (kv/fetch (.bucket c) k :head-only true))))
  9. (hit [this k]
  10. this)
  11. (miss [c k v]
  12. (kv/store (.bucket c) k v :content-type (.content-type c) :w (.w c))
  13. c)
  14. (evict [c k]
  15. (kv/delete (.bucket c) k :w (.w c))
  16. c)
  17. (seed [c m]
  18. (doseq [[k v] m]
  19. (kv/store (.bucket c) k v :content-type (.content-type c) :w (.w c)))
  20. c))
Add Comment
Please, Sign In to add comment