(all cache)
returns all values in the cache
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/all)) => {:a 1, :b 2}
returns all values in the cache (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/all)) => {:a 1, :b 2}
(batch cache add-values)
(batch cache add-values add-expiry remove-vec)
performs multiple operations in the cache
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/batch {:c 3 :d 4} {} [:b]) (cache/all)) => {:a 1, :c 3, :d 4}
performs multiple operations in the cache (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/batch {:c 3 :d 4} {} [:b]) (cache/all)) => {:a 1, :c 3, :d 4}
(cache)
(cache m)
creates an active cache
(cache {:type :mock :initial {:a {:value 1}} :file {:path "dev/scratch/test.edn" ;;:load true :reset true}}) ;;=> #cache.mock{:a 1}
creates an active cache (cache {:type :mock :initial {:a {:value 1}} :file {:path "dev/scratch/test.edn" ;;:load true :reset true}}) ;;=> #cache.mock{:a 1}
(clear cache)
clears the cache
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/clear) (cache/all)) => {}
clears the cache (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/clear) (cache/all)) => {}
(count cache)
returns number of active keys in the cache
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/count)) => 2
returns number of active keys in the cache (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/count)) => 2
(create m)
creates a cache that is component compatible
(cache/create {:type :mock :file {:path "dev/scratch/test.edn" :reset true}}) ;;=> #cache.mock<uninitiased>
creates a cache that is component compatible (cache/create {:type :mock :file {:path "dev/scratch/test.edn" :reset true}}) ;;=> #cache.mock<uninitiased>
(delete cache key)
deletes given key
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/delete :b) (cache/all)) => {:a 1}
deletes given key (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/delete :b) (cache/all)) => {:a 1}
(expired? cache key)
checks if a given key time is expired
(binding [base/current 1000] (-> (cache {:type :mock :initial {:a {:value 1 :expiration 1001}}}) (cache/expired? :a))) => false
checks if a given key time is expired (binding [base/*current* 1000] (-> (cache {:type :mock :initial {:a {:value 1 :expiration 1001}}}) (cache/expired? :a))) => false
(expiry cache key)
return the expiry of a key in seconds
(binding [base/current 1000] (-> (cache {:type :mock :initial {:a {:value 1 :expiration 7000}}}) (cache/expiry :a))) => 6
return the expiry of a key in seconds (binding [base/*current* 1000] (-> (cache {:type :mock :initial {:a {:value 1 :expiration 7000}}}) (cache/expiry :a))) => 6
(get cache key)
returns the value of a key
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2} :c {:value 3}}}) (cache/get :a)) => 1
returns the value of a key (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2} :c {:value 3}}}) (cache/get :a)) => 1
(keys cache)
returns all keys in the cache
(-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/keys) sort) => [:a :b]
returns all keys in the cache (-> (cache {:type :mock :initial {:a {:value 1} :b {:value 2}}}) (cache/keys) sort) => [:a :b]
(set cache key value)
(set cache key value expiry)
sets the value with or optional expiry
(-> (cache) (cache/set :a 1) :state deref) => {:a {:value 1}}
sets the value with or optional expiry (-> (cache) (cache/set :a 1) :state deref) => {:a {:value 1}}
(touch cache key expiry)
renews the expiration time for a given key
(binding [base/current 1000] (-> (cache {:type :mock :initial {:a {:value 1 :expiration 1001}}}) (cache/touch :a 10) :state deref)) => {:a {:value 1, :expiration 11000}}
renews the expiration time for a given key (binding [base/*current* 1000] (-> (cache {:type :mock :initial {:a {:value 1 :expiration 1001}}}) (cache/touch :a 10) :state deref)) => {:a {:value 1, :expiration 11000}}
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close