Liking cljdoc? Tell your friends :D

cljdoc.util.sqlite-cache

Provides SQLCache, an implementation of clojure.core.cache/CacheProtocol.

It is used with clojure.core.memoize/PluggableMemoization

This namespace exposes memo-sqlite function which takes a function to memoize and cache-spec, it retuns the memoized function. This function uses the SQLCache for memoization.

Provides `SQLCache`, an implementation of `clojure.core.cache/CacheProtocol`.

It is used with `clojure.core.memoize/PluggableMemoization`

This namespace exposes `memo-sqlite` function which takes a
function to memoize and cache-spec, it retuns the memoized function.
This function uses the `SQLCache` for memoization.
raw docstring

cache!clj

(cache! k
        v
        {:keys [db-spec key-prefix serialize-fn table key-col value-col ttl]})
source

evict!clj

(evict! k {:keys [db-spec key-prefix table key-col]})
source

fetch!clj

(fetch! k {:keys [db-spec key-prefix table key-col]})
source

fetch-item!clj

(fetch-item! k
             {:keys [db-spec key-prefix deserialize-fn table key-col
                     value-col]})

Performs lookup by querying on the cache table. Retuens deserialized cached item.

Performs lookup by querying on the cache table.
Retuens deserialized cached item.
sourceraw docstring

memo-sqliteclj

(memo-sqlite f cache-spec)

Memoizes the given function f using SQLCache for caching. SQLCache uses a SQL backend to store return values of f.

Example usage with SQLite:

(def memo-f
  (memo-sqlite (fn [arg] (Thread/sleep 5000) arg)
               {:key-prefix         "artifact-repository"
                :key-col            "key"
                :value-col          "value"
                :ttl                2000
                :table              "cache"
                :serialize-fn       identity
                :deserialize-fn     read-string
                :db-spec   {:dbtype      "sqlite"
                       :classname   "org.sqlite.JDBC"
                       :subprotocol "sqlite"
                       :subname     "data/my-cache.db"}}))

(memo-f 1) ;; takes more than 5 seconds to return.
(memo-f 1) ;; return immediately from cache.
Memoizes the given function `f` using  `SQLCache` for caching.
`SQLCache` uses a SQL backend to store return values of `f`.

Example usage with SQLite:
```
(def memo-f
  (memo-sqlite (fn [arg] (Thread/sleep 5000) arg)
               {:key-prefix         "artifact-repository"
                :key-col            "key"
                :value-col          "value"
                :ttl                2000
                :table              "cache"
                :serialize-fn       identity
                :deserialize-fn     read-string
                :db-spec   {:dbtype      "sqlite"
                       :classname   "org.sqlite.JDBC"
                       :subprotocol "sqlite"
                       :subname     "data/my-cache.db"}}))

(memo-f 1) ;; takes more than 5 seconds to return.
(memo-f 1) ;; return immediately from cache.
```
sourceraw docstring

query-templatesclj

source

refresh!clj

(refresh! k
          v
          {:keys [db-spec key-prefix table key-col value-col serialize-fn ttl]})
source

seed!clj

(seed! {:keys [db-spec key-prefix table key-col value-col]})
source

stale?clj

(stale? {:keys [ttl cached_ts]})

Tests if ttl has expired for a cached item.

When ttl is nil item is not stale. Otherwise ttl is compared with cached_ts.

Tests if `ttl` has expired for a cached item.

When `ttl` is `nil` item is not stale.
Otherwise `ttl` is compared with `cached_ts`.
sourceraw docstring

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

× close