(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}(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}}(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)
=> {}(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(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
(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}}(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](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](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(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](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}}(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}}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |