Liking cljdoc? Tell your friends :D

hara.platform.cache.base


*current*clj


all-atomclj

(all-atom atom)

returns all valid entries in the atom

(binding [current 1000] (-> (atom {:a {:value 1 :expiration 1001} :b {:value 2} :c {:value 3 :expiration 1000}}) (all-atom))) => {:a 1, :b 2}

returns all valid entries in the atom

(binding [*current* 1000]
  (-> (atom {:a {:value 1
                 :expiration 1001}
             :b {:value 2}
             :c {:value 3
                 :expiration 1000}})
      (all-atom)))
=> {:a 1, :b 2}
raw docstring

batch-atomclj

(batch-atom atom add-values add-expiry remove-vec)

creates a batched operation of inserts and deletes

(binding [current 1000] (-> (atom {:a {:value 1} :b {:value 2}}) (batch-atom {:c 3 :d 4} {:c 10} [:a]) deref)) => {:b {:value 2}, :c {:value 3, :expiration 11000}, :d {:value 4}}

creates a batched operation of inserts and deletes

(binding [*current* 1000]
  (-> (atom {:a {:value 1}
             :b {:value 2}})
      (batch-atom {:c 3 :d 4}
                  {:c 10}
                  [:a])
      deref))
=> {:b {:value 2},
    :c {:value 3, :expiration 11000},
    :d {:value 4}}
raw docstring

clear-atomclj

(clear-atom atom)

resets the atom to an empty state

(-> (atom {:a {:value 1} :b {:value 2}}) (clear-atom) deref) => {}

resets the atom to an empty state

(-> (atom {:a {:value 1}
           :b {:value 2}})
    (clear-atom)
    deref)
=> {}
raw docstring

count-atomclj

(count-atom atom)

returns all valid entries in the atom

(binding [current 1000] (-> (atom {:a {:value 1 :expiration 1001} :b {:value 2} :c {:value 3 :expiration 1000}}) (count-atom))) => 2

returns all valid entries in the atom

(binding [*current* 1000]
  (-> (atom {:a {:value 1
                 :expiration 1001}
             :b {:value 2}
             :c {:value 3
                 :expiration 1000}})
      (count-atom)))
=> 2
raw docstring

currentclj

(current)
(current curr)

returns the current time that can be specified for testing

(current) ;;=> 1500088974499

(binding [current 1000] (current)) => 1000

returns the current time that can be specified for testing

(current)
;;=> 1500088974499

(binding [*current* 1000]
  (current))
=> 1000
raw docstring

delete-atomclj

(delete-atom atom key)

returns all valid entries in the atom

(-> (atom {:a {:value 1} :b {:value 2}}) (delete-atom :b) deref) => {:a {:value 1}}

returns all valid entries in the atom

(-> (atom {:a {:value 1}
           :b {:value 2}})
    (delete-atom :b)
    deref)
=> {:a {:value 1}}
raw docstring

expired?-atomclj

(expired?-atom atom key)

checks if key is expired

(binding [current 1000] (let [atom (atom {:a {:value 1 :expiration 999} :b {:value 2} :c {:value 1 :expiration 1001}})] [(expired?-atom atom :a) (expired?-atom atom :b) (expired?-atom atom :c)])) => [true false false]

checks if key is expired

(binding [*current* 1000]
  (let [atom (atom {:a {:value 1
                        :expiration 999}
                    :b {:value 2}
                    :c {:value 1
                        :expiration 1001}})]
    [(expired?-atom atom :a)
     (expired?-atom atom :b)
    (expired?-atom atom :c)]))
=> [true false false]
raw docstring

expiry-atomclj

(expiry-atom atom key)

checks if key is expired

(binding [current 1000] (let [atom (atom {:a {:value 1 :expiration 999} :b {:value 2} :c {:value 1 :expiration 8000}})] [(expiry-atom atom :a) (expiry-atom atom :b) (expiry-atom atom :c)])) => [:expired :never 7]

checks if key is expired

(binding [*current* 1000]
  (let [atom (atom {:a {:value 1
                        :expiration 999}
                    :b {:value 2}
                    :c {:value 1
                        :expiration 8000}})]
    [(expiry-atom atom :a)
     (expiry-atom atom :b)
    (expiry-atom atom :c)]))
=> [:expired :never 7]
raw docstring

get-atomclj

(get-atom atom key)

sets the value of an atom (-> (atom {:hello {:value :world}}) (get-atom :hello)) => :world

sets the value of an atom
(-> (atom {:hello {:value :world}})
    (get-atom :hello))
=> :world
raw docstring

keys-atomclj

(keys-atom atom)

returns all valid entries in the atom

(binding [current 1000] (-> (atom {:a {:value 1 :expiration 1001} :b {:value 2} :c {:value 3 :expiration 1000}}) (keys-atom) sort)) => [:a :b]

returns all valid entries in the atom

 (binding [*current* 1000]
   (-> (atom {:a {:value 1
                  :expiration 1001}
              :b {:value 2}
              :c {:value 3
                  :expiration 1000}})
       (keys-atom)
       sort))
=> [:a :b]
raw docstring

set-atomclj

(set-atom atom key value)
(set-atom atom key value expiry)

sets the value of an atom (-> (atom {}) (set-atom :hello :world) deref) => {:hello {:value :world}}

(binding [current 1000] (-> (atom {}) (set-atom :hello :world 1000) deref)) => {:hello {:value :world, :expiration 1001000}}

sets the value of an atom
(-> (atom {})
    (set-atom :hello :world)
    deref)
=> {:hello {:value :world}}

(binding [*current* 1000]
  (-> (atom {})
      (set-atom :hello :world 1000)
      deref))
=> {:hello {:value :world,
            :expiration 1001000}}
raw docstring

touch-atomclj

(touch-atom atom key expiry)

extend expiration time if avaliable

(binding [current 1000] (-> (atom {:a {:value 1 :expiration 1001} :b {:value 2}}) (touch-atom :a 10) (touch-atom :b 10) deref)) => {:a {:value 1, :expiration 11000} :b {:value 2}}

extend expiration time if avaliable

(binding [*current* 1000]
  (-> (atom {:a {:value 1
                 :expiration 1001}
             :b {:value 2}})
      (touch-atom :a 10)
      (touch-atom :b 10)
      deref))
=> {:a {:value 1, :expiration 11000}
   :b {:value 2}}
raw docstring

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

× close