Data storage and persistence by API call parameters.
This namespace helps structure persisted data so it is remembered by the API call parameters originally used to query it from the provider's API. This is because data caching only is valid for queries using the same parameter set.
Data is also separated by cloud provider and data type. For example, OCI usage data is namespaced
to :oci-usage/field to avoid field type collisions across clouds and metric types.
The known fields that must be indexed are declared inside service.model. We let the database
automatically declare schema entries for everything that doesn't need to be indexed when those
fields are first encountered.
Querying by date range is handled inside store.cache.
Data storage and persistence by API call parameters. This namespace helps structure persisted data so it is remembered by the API call parameters originally used to query it from the provider's API. This is because data caching only is valid for queries using the same parameter set. Data is also separated by cloud provider and data type. For example, OCI usage data is namespaced to `:oci-usage/field` to avoid field type collisions across clouds and metric types. The known fields that must be indexed are declared inside `service.model`. We let the database automatically declare schema entries for everything that doesn't need to be indexed when those fields are first encountered. Querying by date range is handled inside `store.cache`.
(add-query-conditions provider kind entity-symbol q & result-condition-kvs)Takes provider, kind, entity-symbol, a base query q, and an optional
vararg of alternating k/v vectors representing additional query conditions
to add to the base query.
Returns a new query with the additional conditions added in the :where clause,
where the keys are namespaced to <provider>-<kind>.
For example, if you have a base query that looks for cached results based on :start-date, you can use this function to add additional conditions for :cloud and :granularity without having to manually namespace those keys or worry about the structure of the query.
Takes `provider`, `kind`, `entity-symbol`, a base query `q`, and an optional vararg of alternating k/v vectors representing additional query conditions to add to the base query. Returns a new query with the additional conditions added in the :where clause, where the keys are namespaced to `<provider>-<kind>`. For example, if you have a base query that looks for cached results based on :start-date, you can use this function to add additional conditions for :cloud and :granularity without having to manually namespace those keys or worry about the structure of the query.
(conditions provider kind & condition-kvs)Takes provider, kind, and a vararg of k/v vectors representing query conditions
against ?memoized-data.
Returns a vector of Datalog query conditions with keys namespaced to <provider>-<kind>.
For example, you can use this function to generate the additional conditions for a query that looks for cached results based on :start-date, without having to manually namespace those keys or worry about the structure of the conditions.
Takes `provider`, `kind`, and a vararg of k/v vectors representing query conditions against `?memoized-data`. Returns a vector of Datalog query conditions with keys namespaced to `<provider>-<kind>`. For example, you can use this function to generate the additional conditions for a query that looks for cached results based on :start-date, without having to manually namespace those keys or worry about the structure of the conditions.
(connect! initial-schema)Connects to the Datahike database, creating it and installing a basic schema if it doesn't exist.
Connects to the Datahike database, creating it and installing a basic schema if it doesn't exist.
(delete-db!)(delete-db! config)Deletes the Datahike database at the configured location.
Deletes the Datahike database at the configured location.
(disconnect!)Disconnects from the current Datahike database.
Disconnects from the current Datahike database.
(fetch provider data-kind param-name-keywords & params-kvs)Fetches cached data for the given provider, kind, and param-name-keywords
that match the provided query conditions.
provider and kind are used to namespace the query conditions to ensure we
are fetching the correct data.
param-name-keywords is a vector of keywords representing the parameter names
that were used to cache the data, which is used to look up the appropriate cache entry.
The optional vararg of k/v vectors represent additional query conditions to filter the cached results, where keys are unqualified keywords that will be namespaced based on the provider and kind.
Returns a sequence of cached results that match the query conditions.
Fetches cached data for the given `provider`, `kind`, and `param-name-keywords` that match the provided query conditions. `provider` and `kind` are used to namespace the query conditions to ensure we are fetching the correct data. `param-name-keywords` is a vector of keywords representing the parameter names that were used to cache the data, which is used to look up the appropriate cache entry. The optional vararg of k/v vectors represent additional query conditions to filter the cached results, where keys are unqualified keywords that will be namespaced based on the provider and kind. Returns a sequence of cached results that match the query conditions.
(fetch-by-cache-key cache-key)Fetches cached data matching the given cache-key.
Returns a flat sequence of result entity maps (with provider+kind namespace).
Fetches cached data matching the given `cache-key`. Returns a flat sequence of result entity maps (with provider+kind namespace).
(memoized-data-query param-name-keywords & extra-clauses)Return a Datalog query for fetching memoized data based on the given param-name-keywords that is
suitable for adding additional query conditions using concat.
The query defines ?memoized-data as the entity that holds the cached results and expects a vector
of parameter name keywords that will be used to look up the appropriate cache entry based on the
:memoized/parameter-names attribute.
To add additional query clauses, pass a vector for each additional clause to the extra-clauses vararg
parameter, referencing ?memoized-data as needed. Ensure that the keys in the additional clauses are
in the form <provider>-<data-kind>/<key-name>.
Return a Datalog query for fetching memoized data based on the given `param-name-keywords` that is suitable for adding additional query conditions using `concat`. The query defines `?memoized-data` as the entity that holds the cached results and expects a vector of parameter name keywords that will be used to look up the appropriate cache entry based on the `:memoized/parameter-names` attribute. To add additional query clauses, pass a vector for each additional clause to the `extra-clauses` vararg parameter, referencing `?memoized-data` as needed. Ensure that the keys in the additional clauses are in the form `<provider>-<data-kind>/<key-name>`.
(memoized-data-query-by-key cache-key & extra-clauses)Like memoized-data-query but matches on :memoized/cache-key instead of
:memoized/parameter-names.
Like `memoized-data-query` but matches on `:memoized/cache-key` instead of `:memoized/parameter-names`.
(memory-db-conn schema)(memory-db-conn config schema)Create an in-memory database and return its configuration map with a :store/conn to the database assoc'd into it.
Remember to delete the database later! Calling delete-db! on the
database config map will automatically release the connection also.
Create an in-memory database and return its configuration map with a :store/conn to the database assoc'd into it. Remember to delete the database later! Calling `delete-db!` on the database config map will automatically release the connection also.
(q query & params)Like datahike.api/q but always operates on the active *conn*.
Like datahike.api/q but always operates on the active `*conn*`.
(store provider kind param-name-keywords data)(store provider kind cache-key param-name-keywords data)(store provider kind cache-key param-name-keywords data queried-start)Stores a vector of map data by the given provider, kind, and param-name-keywords.
When cache-key is provided (5/6-arity), the cache-key and cached-at timestamp are
stored alongside the legacy parameter-names key. When omitted (4-arity), only the
legacy parameter-names key is stored (backward compatibility).
When queried-start is provided (6-arity), it is stored as :memoized/queried-start,
recording the start date of the API call that produced this batch. Used by
call-cached-api to detect leading gaps in the cache.
Stores a vector of map `data` by the given `provider`, `kind`, and `param-name-keywords`. When `cache-key` is provided (5/6-arity), the cache-key and cached-at timestamp are stored alongside the legacy parameter-names key. When omitted (4-arity), only the legacy parameter-names key is stored (backward compatibility). When `queried-start` is provided (6-arity), it is stored as :memoized/queried-start, recording the start date of the API call that produced this batch. Used by `call-cached-api` to detect leading gaps in the cache.
(with-db-conn conn & body)Executes body with *conn* bound to a different database connection.
Executes body with `*conn*` bound to a different database connection.
(with-temporary-db & body)Create a temporary in-memory database, connect to it, execute body, and then close the connection and delete the database.
Create a temporary in-memory database, connect to it, execute body, and then close the connection and delete the database.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |