potamic.util
Common utilities.
->int
(->int s)
Returns string s
parsed to integer.
Examples:
See also:
->str
(->str x)
Returns a string representation of symbol. This is similar to calling str
on a symbol except that keywords will not contain a preceding colon character. The keyword :x/y
will yield “x/y” instead of “:x/y”.
Examples:
(require '[potamic.util :as util])
;; all of the following are identical
(util/->str :my/queue)
(util/->str 'my/queue)
(util/->str "my/queue")
;= "my/queue"
See also:
potamic.util/<-str
<-str
(<-str x)
Returns keyword for x
if x
is a string and doesn’t start with a number, else returns x
as-is.
NOTE: Redis Stream IDs won’t be coerced to keywords.
Examples:
See also:
potamic.util/->str
encode-map-vals
(encode-map-vals m)
Returns map after encoding map vals by calling nippy/freeze
on them. Nested maps are encoded wholesale as Redis/KeyDB streams don’t allow nesting.
Examples:
(require '[potamic.util :as util])
(def m {:a 111 :b {:c "333" :d :my/namespaced-key}})
(util/encode-map-vals m)
;= {:a #object["[B" 0x7225a307 "[B@7225a307"]
;= :b #object["[B" 0x141cc645 "[B@141cc645"]}
make-exception
(make-exception e)
prep-cmd
(prep-cmd args)
Returns concatenated vector of arguments (without using concat) to be applied to a Carmine/Redis command.
Examples:
See also:
RECURSIVE-WALK
(Implemtation detail)
Compiled path for nested data structures.
remove-conn
(remove-conn x)
time->milliseconds
(time->milliseconds t)
Converts high-level time syntax (e.g. [5 :seconds]
) to milliseconds. If t
is an integer, or if :milli
/millis
is provided as interval
, it is returned as-is. Returns an integer for milliseconds.
Intervals |
---|
:milli /:millis |
:second /:seconds |
:minute /:minutes |
:hour /:hours |
Examples:
(util/time->milliseconds [5 :seconds])
;= 5000
(util/time->milliseconds [1 :second])
;= 1000
(util/time->milliseconds [5 :hours])
;= 18000000
(util/time->milliseconds [1234 :millis])
;= 1234
(util/time->milliseconds 1234))
;= 1234
uuid
(uuid)