We're updating the issue view to help you get more done. 

TTL cache's has? doesn't check existence of value in the underlying cache

Description

(extracted from the comments thread of the CCACHE-15)

In case TTL cache is wrapped around other cache capable of evicting values based on some logic (e. g., LRU cache) TTL's has? would return true until TTL period of the given key is expired even if the underlying cache doesn't contain the value.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 user> (require '[clojure.core.cache :as cache]) user> (let [C (-> {} (cache/lru-cache-factory :threshold 1) ; base cache that contains one element at most (cache/ttl-cache-factory :ttl 360000) ; TTL cache with big TTL to ensure key is not expired ) C2 (if (cache/has? C :c) (cache/hit C :c) (cache/miss C :c 42)) C3 (if (cache/has? C2 :d) (cache/hit C2 :d) (cache/miss C2 :d 42))] [(cache/has? C3 :c) (cache/lookup C3 :c)]) [true nil] ; TTL cache reports it contains the given key but value is actually not present

Environment

None

Status

Assignee

Sean Corfield

Reporter

Ivan Kryvoruchko

Labels

None

Approval

None

Patch

Code and Test

Priority

Major