Liking cljdoc? Tell your friends :D

clj-foundationdb.core


*subspace*clj

source

clear-allclj

(clear-all tr)

Clear all keys from the database

Clear all  keys from the database
sourceraw docstring

clear-keyclj

(clear-key tr key)

Clear a key from the database

(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (clear-key tr key))))
Clear a key from the database

```
(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (clear-key tr key))))
```
sourceraw docstring

clear-rangeclj

(clear-range tr begin)
(clear-range tr begin end)

Clear a range of keys from the database. When only begin is given then the keys with starting with the tuple are cleared. When begin and end are specified then end is exclusive of the range to be cleared.

(let [fd    (select-api-version 520)
      begin "foo"]
(with-open [db (open fd)]
   (tr! db (clear-range tr begin))))

(let [fd    (select-api-version 520)
      begin "foo"
      end   "foo"]
(with-open [db (open fd)]
   (tr! db (clear-range tr begin end))))
Clear a range of keys from the database.
When only begin is given then the keys with starting with the tuple are cleared.
When begin and end are specified then end is exclusive of the range to be cleared.

```
(let [fd    (select-api-version 520)
      begin "foo"]
(with-open [db (open fd)]
   (tr! db (clear-range tr begin))))

(let [fd    (select-api-version 520)
      begin "foo"
      end   "foo"]
(with-open [db (open fd)]
   (tr! db (clear-range tr begin end))))
```
sourceraw docstring

first-greater-or-equalclj

(first-greater-or-equal tr key)
(first-greater-or-equal tr key limit)

Returns key and value pairs with keys greater than or equal to the given key for the given limit

(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (first-greater-or-equal tr key))))
Returns key and value pairs with keys greater than or equal to the given key for the given limit

```
(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (first-greater-or-equal tr key))))
```
sourceraw docstring

first-greater-thanclj

(first-greater-than tr key)
(first-greater-than tr key limit)

Returns key and value pairs with keys greater than the given key for the given limit

(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (first-greater-than tr key))))
Returns key and value pairs with keys greater than the given key for the given limit

```
(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (first-greater-than tr key))))
```
sourceraw docstring

get-allclj

(get-all tr)

Get all key values as a vector

Get all key values as a vector
sourceraw docstring

get-rangeclj

(get-range tr begin)
(get-range tr begin end)

Get a range of key values as a vector

(let [fd    (select-api-version 520)
      begin "foo"
      end   "foo"]
(with-open [db (open fd)]
   (tr! db (get-range tr begin end))))
Get a range of key values as a vector

```
(let [fd    (select-api-version 520)
      begin "foo"
      end   "foo"]
(with-open [db (open fd)]
   (tr! db (get-range tr begin end))))
```
sourceraw docstring

get-range-startswithclj

(get-range-startswith tr prefix)

Get a range of key values as a vector that starts with prefix

(let [fd     (select-api-version 520)
      prefix "f"]
(with-open [db (open fd)]
   (tr! db (get-range-startswith tr key prefix))))
Get a range of key values as a vector that starts with prefix

```
(let [fd     (select-api-version 520)
      prefix "f"]
(with-open [db (open fd)]
   (tr! db (get-range-startswith tr key prefix))))
```
sourceraw docstring

get-valclj

(get-val tr key & {:keys [subspace coll] :or {subspace *subspace* coll false}})

Get the value for the given key. Accepts the below :

:subspace - Subspace to be prefixed :coll - Boolean to indicate if the value needs to be deserialized as collection

(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db
        (get-val tr key))))

(let [fd    (select-api-version 520)
     key   "foo"
     value [1 2 3]]
(with-open [db (open fd)]
  (tr! db
       (set-val tr key value)
       (get-val tr key) ;; 1
       (get-val tr key :coll true)))) ;; [1 2 3]
Get the value for the given key. Accepts the below :

:subspace - Subspace to be prefixed
:coll     - Boolean to indicate if the value needs to be deserialized as collection

```
(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db
        (get-val tr key))))

(let [fd    (select-api-version 520)
     key   "foo"
     value [1 2 3]]
(with-open [db (open fd)]
  (tr! db
       (set-val tr key value)
       (get-val tr key) ;; 1
       (get-val tr key :coll true)))) ;; [1 2 3]
```
sourceraw docstring

last-less-or-equalclj

(last-less-or-equal tr key)
(last-less-or-equal tr key limit)

Returns key and value pairs with keys less than or equal the given key for the given limit

(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (last-less-or-equal tr key))))
Returns key and value pairs with keys less than or equal the given key for the given limit

```
(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (last-less-or-equal tr key))))
```
sourceraw docstring

last-less-thanclj

(last-less-than tr key)
(last-less-than tr key limit)

Returns key and value pairs with keys less than the given key for the given limit

(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (last-less-than tr key))))
Returns key and value pairs with keys less than the given key for the given limit

```
(let [fd  (select-api-version 520)
      key "foo"]
(with-open [db (open fd)]
   (tr! db (last-less-than tr key))))
```
sourceraw docstring

make-subspaceclj

(make-subspace prefix key)

Returns a key with name as prefix

(make-subspace ["class" "intro"] ["algebra"]) returns ("class" "intro" "algebra")
Returns a key with name as prefix

```
(make-subspace ["class" "intro"] ["algebra"]) returns ("class" "intro" "algebra")
```
sourceraw docstring

serializable?clj

source

set-keysclj

(set-keys tr keys value)

Set given keys with the value

(let [fd    (select-api-version 520)
      keys  ["foo" "baz"]
      value "bar"]
(with-open [db (open fd)]
   (tr! db (set-keys tr keys value))))
Set given keys with the value

```
(let [fd    (select-api-version 520)
      keys  ["foo" "baz"]
      value "bar"]
(with-open [db (open fd)]
   (tr! db (set-keys tr keys value))))
```
sourceraw docstring

set-valclj

(set-val tr key value & {:keys [subspace] :or {subspace *subspace*}})

Set a value for the key. Accepts the below :

:subspace - Subspace to be prefixed

(let [fd    (select-api-version 520)
      key   "foo"
      value "bar"]
(with-open [db (open fd)]
   (tr! db
        (set-val tr key value))))
Set a value for the key. Accepts the below :

:subspace - Subspace to be prefixed

```
(let [fd    (select-api-version 520)
      key   "foo"
      value "bar"]
(with-open [db (open fd)]
   (tr! db
        (set-val tr key value))))
```
sourceraw docstring

tr!cljmacro

(tr! db & actions)

Transaction macro to perform actions. Always use tr for actions inside each action since the transaction variable is bound to tr in the functions.

(let [fd    (select-api-version 520)
      key   "foo"
      value "bar"]
(with-open [db (open fd)]
   (tr! db
        (set-val tr key value)
        (get-val tr key))))
Transaction macro to perform actions. Always use tr for actions inside
each action since the transaction variable is bound to tr in the functions.

```
(let [fd    (select-api-version 520)
      key   "foo"
      value "bar"]
(with-open [db (open fd)]
   (tr! db
        (set-val tr key value)
        (get-val tr key))))
```
sourceraw docstring

tr?clj

source

watchclj

(watch tr key callback)

A key to watch and a callback function to be executed on change. It returns a future object that is realized when there is a change to key. Change in key value or clearing the key is noted as a change. A set statement with the old value is not a change.

(let [fd    (select-api-version 520)
     key    "foo"
     value  "bar"]
(with-open [db (open fd)]
  (tr! db
       (clear-key tr key)
       (watch tr key #(println "key is set"))
       (set-val tr key value)
       (watch tr key #(println "key is changed to 1"))
       (set-val tr key value) ;; Doesn't trigger watch
       (set-val tr key "1")
       (watch tr key #(println "cleared key"))
       (clear-key tr key))))

key is set key is changed to 1 cleared key

A key to watch and a callback function to be executed on change. It returns a future object
that is realized when there is a change to key. Change in key value or clearing the key
is noted as a change. A set statement with the old value is not a change.

```
(let [fd    (select-api-version 520)
     key    "foo"
     value  "bar"]
(with-open [db (open fd)]
  (tr! db
       (clear-key tr key)
       (watch tr key #(println "key is set"))
       (set-val tr key value)
       (watch tr key #(println "key is changed to 1"))
       (set-val tr key value) ;; Doesn't trigger watch
       (set-val tr key "1")
       (watch tr key #(println "cleared key"))
       (clear-key tr key))))
```
key is set
key is changed to 1
cleared key

sourceraw docstring

with-subspacecljmacro

(with-subspace prefix & actions)

Sets and gets the keys with the given subspace key prefixed. This essentially executes with code binding the given prefix to subspace.

(let [fd    (select-api-version 520)
      key   "foo"
      value "bar"]
  (with-open [db (open fd)]
    (tr! db
         (clear-all tr)
         (with-subspace "class"
           (set-val tr key value)
           (get-val tr key))
          (nil? (get-val tr key)))))
Sets and gets the keys with the given subspace key prefixed.
This essentially executes with code binding the given prefix to *subspace*.

```
(let [fd    (select-api-version 520)
      key   "foo"
      value "bar"]
  (with-open [db (open fd)]
    (tr! db
         (clear-all tr)
         (with-subspace "class"
           (set-val tr key value)
           (get-val tr key))
          (nil? (get-val tr key)))))
```
sourceraw docstring

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

× close