Liking cljdoc? Tell your friends :D

com.brunobonacci.sophia


all-metric-valuesclj

(all-metric-values {:keys [available-keys] :as metric-env})

Returns a map with the current value of all database metrics for the given environment.

Returns a map with the current value of all database metrics for the
given environment.
sourceraw docstring

begin-transactionclj

(begin-transaction {:keys [env] :as sophia})

Begins a transaction for the given sophia database

Begins a transaction for the given sophia database
sourceraw docstring

commitclj

(commit {:keys [env trx] :as transaction} & {:keys [silent]})

Commits the transaction for the given database. There are three possible outcomes:

  • :ok - the transaction is committed successfully
  • :rollback - the transaction is aborted because another transaction completed before this and updated the same key(s).
  • :lock - another transaction has a lock on one or more keys is pending commit in another transaction. It could be retried in a later time.
Commits the transaction for the given database.
There are three possible outcomes:

   - :ok - the transaction is committed successfully
   - :rollback - the transaction is aborted because
        another transaction completed before this
        and updated the same key(s).
   - :lock - another transaction has a lock on one
        or more keys is pending commit in another
        transaction. It could be retried in a later time.
sourceraw docstring

cursorclj

(cursor {:keys [env] :as sophia})

Returns a cursor with a snapshot isolation level consistency which means new writes won't affect the query result. This ensures that all the reads are consistent in regards to the point in time this cursor is created. The cursor must be closed (with .close()) once terminated. Best used with with-open Clojure macro.

Returns a cursor with a snapshot isolation level consistency
which means new writes won't affect the query result.
This ensures that all the reads are consistent in regards
to the point in time this cursor is created.
The cursor must be closed (with `.close()`) once terminated.
Best used with `with-open` Clojure macro.
sourceraw docstring

delete-key!clj

(delete-key! {:keys [env trx] :as sophia} db key)

It deletes a key. like set-value! if a transaction is passed the change will only be visible when the transaction is committed. It returns nil.

It deletes a key. like `set-value!` if a transaction is
passed the change will only be visible when the transaction
is committed. It returns `nil`.
sourceraw docstring

get-valueclj

(get-value {:keys [env trx] :as sophia} db key)
(get-value {:keys [env trx] :as sophia} db key default-value)

Retrieve the current value of a key. If a transaction is passed as sophia environment the value could have been changed in the transaction; in that case the updated value will be returned (read your own writes). To read the last committed value just use the main sophia environment. If the key is not found nil is returned unless a default-value is provided.

Retrieve the current value of a key. If a transaction is passed as
`sophia` environment the value could have been changed in the
transaction; in that case the updated value will be returned
(read your own writes). To read the last committed value
just use the main sophia environment.
If the key is not found `nil` is returned unless
a `default-value` is provided.
sourceraw docstring

ICursorcljprotocol

cursor-refclj

(cursor-ref _)

Internal cursor ref

Internal cursor ref

sophia-envclj

(sophia-env _)

Sophia db configuration and environment

Sophia db configuration and environment

sophia-refclj

(sophia-ref _)

Sophia native env ref

Sophia native env ref
source

metric-envclj

(metric-env {:keys [env] :as sophia-env})

returns a cacheable metrics environment which can be used to retrieve specific database metrics.

returns a cacheable metrics environment which can be used to retrieve specific
database metrics.
sourceraw docstring

metric-valueclj

(metric-value {:keys [available-keys] {:keys [env]} :sophia-env :as metric-env}
              metric)

returns the current value of a metric if available, nil otherwise.

returns the current value of a metric if available, nil otherwise.
sourceraw docstring

range-queryclj

(range-query cursor
             db
             &
             {:keys [key order search-type]
              :as opts
              :or {order :asc search-type :index-scan-inclusive}})

Returns a lazy-sequence of all items matching the query. The output is a lazy-sequence of tuples if the following form [key value]. Keys will be ordered according to the :order option (default :asc).

Three types of query are available:

  • full table scans - The database is traversed from the beginning towards the end. Keys are alphabetically ordered. Order can be reversed via :order :desc option. example:

    (with-open [cur (sph/cursor env)] (into {} (sph/range-query cur "accounts")))

  • seek and scan - By providing a key argument you can seek a specific point in the key-range and scan forward or backward from that key. The direction of the scanning can be controlled via the :order parameter. Finally you can control whether the item matching key should be included or excluded (default :index-scan-inclusive) from the search via :search-type option. example:

    (with-open [cur (sph/cursor env)] (into [] (sph/range-query cur "accounts" :key "user1" :order :desc)))

  • prefix - By providing a key argument together with :search-type :prefix you can provide a common prefix for the keys you are searching for. Note that for this type of queries the :order isn't considered at all and just ignored, keys will always be returned in ascending order. example:

    (with-open [cur (sph/cursor env)] (into [] (sph/range-query cur "accounts" :key "user" :search-type :prefix)))

Syntax:

  • cursor (required) snapshot isolation
  • db (required) the name of the db to run the query onto.
  • :key (optional) A key to seek from which to start scanning from.
  • :order (optional) :asc | :desc (default: :asc)
  • :search-type (optional) valid values: :index-scan-inclusive (default) include the matching key if found as part of the result. :index-scan-exclusive exclude the matching key from the result. :prefix returns all the keys which start with the :key argument

If none of the keys match the query or the db it is empty an empty sequence is returned.

Returns a lazy-sequence of all items matching the query.
The output is a lazy-sequence of tuples if the following
form `[key value]`. Keys will be ordered according to the
`:order` option (default `:asc`).

Three types of query are available:

  * *full table scans* - The database is traversed from the
    beginning towards the end. Keys are alphabetically ordered.
    Order can be reversed via `:order :desc` option.
    example:

      (with-open [cur (sph/cursor env)]
        (into {} (sph/range-query cur "accounts")))

  * *seek and scan* - By providing a `key` argument
    you can seek a specific point in the key-range
    and scan forward or backward from that key.
    The direction of the scanning can be controlled
    via the `:order` parameter. Finally you can control
    whether the item matching `key` should be included
    or excluded (default `:index-scan-inclusive`) from
    the search via `:search-type` option.
    example:

      (with-open [cur (sph/cursor env)]
        (into []
          (sph/range-query cur "accounts"
                    :key "user1" :order :desc)))

  * *prefix* - By providing a `key` argument together
    with `:search-type :prefix` you can provide
    a common prefix for the keys you are searching for.
    Note that for this type of queries the `:order`
    isn't considered at all and just ignored, keys will
    always be returned in ascending order.
    example:

      (with-open [cur (sph/cursor env)]
        (into []
          (sph/range-query cur "accounts"
                    :key "user" :search-type :prefix)))


Syntax:

  - *cursor* (required) snapshot isolation
  - *db* (required) the name of the db to run the query onto.
  - *:key* (optional) A key to seek from which to start
       scanning from.
  - *:order* (optional) `:asc` | `:desc` (default: `:asc`)
  - *:search-type* (optional) valid values:
     `:index-scan-inclusive` (default) include the matching key
      if found as part of the result.
     `:index-scan-exclusive` exclude the matching key from the result.
     `:prefix` returns all the keys which start with the `:key` argument

 If none of the keys match the query or the db it is empty an empty
 sequence is returned.
 
sourceraw docstring

rollbackclj

(rollback {:keys [trx] :as transaction})

It aborts the given transaction and discards all the changes associated with it.

It aborts the given transaction and discards all the changes
associated with it.
sourceraw docstring

set-value!clj

(set-value! {:keys [env trx] :as sophia} db key value)

Set the given value to the database. If a transaction is passed as sophia the value will be set only if the transaction is successfully committed. It returns the value which for set in.

Set the given value to the database. If a transaction is passed as
`sophia` the value will be set only if the transaction is
successfully committed.
It returns the value which for set in.
sourceraw docstring

sophiaclj

(sophia config)

Returns a sophia db environment to access the databases

Returns a sophia db environment to access the databases
sourceraw docstring

transact!clj

(transact! env f)

It takes a sophia-env and a function f which presumably updates the database and it runs the function f with a transaction as parameter. At the end it will attempt to commit the transaction, if the commit fails, the transaction will be rolled back and retried automatically. If the function fails the transaction will be rolled back and the error propagated. The function returns what f returns.

It takes a `sophia-env` and a function `f` which presumably updates
the database and it runs the function `f` with a transaction as
parameter. At the end it will attempt to commit the transaction, if
the commit fails, the transaction will be rolled back and retried
automatically. If the function fails the transaction will be rolled
back and the error propagated.  The function returns what `f`
returns.
sourceraw docstring

update-value!clj

(update-value! {:keys [env trx] :as sophia} db key f & args)

Given a key and a function f it applies the function f to the given key's value and it updates it in a transaction. If concurrent update it happens it will retry with a exponential back off delay. If instead of a environment you provide a transaction it will update the given key within the transaction and leave it to the user to commit/retry the transaction. The semantic is similar to clojure.core/update but over a db value. If the key doesn't exists then the is not executed and nil is returned

Given a key and a function `f` it applies the function `f` to the
given key's value and it updates it in a transaction. If concurrent
update it happens it will retry with a exponential back off delay.
If instead of a environment you provide a transaction it will update
the given key within the transaction and leave it to the user to
commit/retry the transaction.
The semantic is similar to clojure.core/update but over a db value.
If the key doesn't exists then the is not executed and nil is returned
sourceraw docstring

upsert-value!clj

(upsert-value! {:keys [env trx] :as sophia} db key f & args)

Same as update-value! but f is applied also when the key doesn't exists.Given a key and a functionfit applies the functionfto the given key's value and it updates it in a transaction. If concurrent update it happens it will retry with a exponential back off delay. If instead of a environment you provide a transaction it will update the given key within the transaction and leave it to the user to commit/retry the transaction. The semantic is similar to clojure.core/update but over a db value. If the key doesn't exists f is applied withnil`

Same as `update-value!` but `f` is applied also when the key doesn't
exists.`
Given a key and a function `f` it applies the function `f` to the
given key's value and it updates it in a transaction. If concurrent
update it happens it will retry with a exponential back off delay.
If instead of a environment you provide a transaction it will update
the given key within the transaction and leave it to the user to
commit/retry the transaction.
The semantic is similar to clojure.core/update but over a db value.
If the key doesn't exists f is applied with `nil`
sourceraw docstring

with-transactioncljmacro

(with-transaction bindings & body)

bindings => [name init ...] Evaluates body in a transaction. At the end of the block the transaction is committed. If an exception occur before the transaction is rolled back.

bindings => [name init ...]
Evaluates body in a transaction. At the end of the block
the transaction is committed. If an exception occur before
the transaction is rolled back.
sourceraw docstring

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

× close