When a CVM instance is used, it relies on a thread-local database which can be manually retrieved using local
.
The thread-local database can be set usint local-set
. Originally, at thread initialization, it corresponds to
the global
database which is common to all threads. Its value can also be altered using global-set
.
Ultimately, the global
database itself returns [[default]] unless user has set its value to another database.
Default [[database]] is an Etch instance. See convex.db
.
When a CVM instance is used, it relies on a thread-local database which can be manually retrieved using [[local]]. The thread-local database can be set usint [[local-set]]. Originally, at thread initialization, it corresponds to the [[global]] database which is common to all threads. Its value can also be altered using [[global-set]]. Ultimately, the [[global]] database itself returns [[default]] unless user has set its value to another database. Default [[database]] is an Etch instance. See [[convex.db]].
Etch is a fast, immutable, append-only database specially tailored for cells.
This namespace provides an API for creating an instance by pointing to a single file. This file
hosts an arbitrarily large map of hash of the encoding of a cell
-> cell
. Hence, reading require
hashes (see convex.cell/hash
from :project/cvm
) and writes primarilty return refs or nil
when not found (see convex.ref
).
Lastly, a root hash can be stored and retrieved. Cell stored at root is typically used to maintain some sort of global state or table tracking what is needed.
Attention. By default, R/W functions use the current thread-local database (see convex.cvm.db
).
Providing an instance explicitly is tricky because when reading, not all data might be retrieved at once.
This is what allows large data, even larger than memory, to be queried: large structures are split into refs
and not all refs are necessarily resolved right away. However, any unresolved ref will be resolved against
the current thread-local database when needed, not the one that was explicitly provided when reading.
In other words, when handling a custom instance, it is best to work on a dedicated thread and call
convex.cvm.db/local-set
.
That being said, instances support multithreading. Being immutable, no thread has to worry that some data might be removed or updated in place.
Etch is a fast, immutable, append-only database specially tailored for cells. This namespace provides an API for creating an instance by pointing to a single file. This file hosts an arbitrarily large map of `hash of the encoding of a cell` -> `cell`. Hence, reading require hashes (see `convex.cell/hash` from `:project/cvm`) and writes primarilty return refs or nil when not found (see [[convex.ref]]). Lastly, a root hash can be stored and retrieved. Cell stored at root is typically used to maintain some sort of global state or table tracking what is needed. **Attention.** By default, R/W functions use the current thread-local database (see [[convex.cvm.db]]). Providing an instance explicitly is tricky because when reading, not all data might be retrieved at once. This is what allows large data, even larger than memory, to be queried: large structures are split into refs and not all refs are necessarily resolved right away. However, any unresolved ref will be resolved against the current thread-local database when needed, not the one that was explicitly provided when reading. In other words, when handling a custom instance, it is best to work on a dedicated thread and call [[convex.cvm.db/local-set]]. That being said, instances support multithreading. Being immutable, no thread has to worry that some data might be removed or updated in place.
A ref
is a reference to a cell. Most of the time, is it used as an intermediary value between a database
and the CVM. Unless refs are handled in reference to an explicit database, database used when resolving is always the current
one bound to the local thread. See convex.cvm.db
, convex.db
.
A direct ref holds a direct reference to a cell whereas a soft ref might release its reference when there is pressure on memory. If needed, a soft ref will fetch its corresponding cell from a database.
A `ref` is a reference to a cell. Most of the time, is it used as an intermediary value between a database and the CVM. Unless refs are handled in reference to an explicit database, database used when resolving is always the current one bound to the local thread. See [[convex.cvm.db]], [[convex.db]]. A **direct ref** holds a direct reference to a cell whereas a **soft ref** might release its reference when there is pressure on memory. If needed, a **soft ref** will fetch its corresponding cell from a database.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close