Liking cljdoc? Tell your friends :D

hara.platform.cache


allclj

(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}
raw docstring

batchclj

(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}
raw docstring

cacheclj

(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}
raw docstring

clearclj

(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))
=> {}
raw docstring

countclj

(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
raw docstring

createclj

(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>
raw docstring

deleteclj

(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}
raw docstring

expired?clj

(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
raw docstring

expiryclj

(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
raw docstring

getclj

(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
raw docstring

keysclj

(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]
raw docstring

setclj

(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}}
raw docstring

touchclj

(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}}
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close