4.9 KiB
Use the influxdb3 create last_cache
command
to create a Last Value Cache (LVC). Provide the following:
-
Database (
-d
,--database
): ({{< req >}}) The name of the database to associate the LVC with. You can also use theINFLUXDB3_DATABASE_NAME
environment variable to specify the database. -
Token (
--token
): ({{< req >}}) Your {{< product-name >}} {{% show-in "enterprise" %}}admin {{% /show-in %}}authentication token. You can also use theINFLUXDB3_AUTH_TOKEN
environment variable to specify the token. -
Table (
-t
,--table
): ({{< req >}}) The name of the table to associate the LVC with. {{% show-in "enterprise" %}} -
Node specification (
-n
,--node-spec
): Specify which nodes the LVC should be configured on. {{% /show-in %}} -
Key columns (
--key-columns
): Specify which columns to include in the primary key of the cache. Rows in the LVC are uniquely identified by their timestamp and key columns, so include all the columns you need to identify each row. These are typically tags, but you can use any columns with the following types:- String
- Integer
- Unsigned integer
- Boolean
-
Value columns (
--value-columns
): Specify which columns to cache as value columns. These are typically fields but can also be tags. By default,time
and columns other than those specified as--key-columns
are cached as value columns. -
Count (
--count
): The number of values to cache per unique key column combination. The supported range is[1-10]
. The default count is1
. -
Time-to-Live (TTL) (
--ttl
): The time-to-live for cached values in humantime form. The default TTL is four hours. -
Cache name: A unique name for the cache. If you don’t provide one, InfluxDB automatically generates a cache name for you.
{{% show-in "core" %}}
{{% code-placeholders "(DATABASE|TABLE|LVC)_NAME|AUTH_TOKEN|(KEY|VALUE)_COLUMNS|COUNT|TTL" %}}
influxdb3 create last_cache \
--database DATABASE_NAME \
--token AUTH_TOKEN \
--table TABLE_NAME \
--key-columns KEY_COLUMNS \
--value-columns VALUE_COLUMNS \
--count COUNT \
--ttl TTL\
LVC_NAME
{{% /code-placeholders %}}
{{% /show-in %}}
{{% show-in "enterprise" %}}
{{% code-placeholders "(DATABASE|TABLE|LVC)_NAME|AUTH_TOKEN|NODE_LIST|(KEY|VALUE)_COLUMNS|COUNT|TTL" %}}
influxdb3 create last_cache \
--database DATABASE_NAME \
--token AUTH_TOKEN \
--table TABLE_NAME \
--node-spec "nodes:NODE_LIST" \
--key-columns KEY_COLUMNS \
--value-columns VALUE_COLUMNS \
--count COUNT \
--ttl TTL\
LVC_NAME
{{% /code-placeholders %}}
{{% /show-in %}}
Replace the following:
- {{% code-placeholder-key %}}
DATABASE_NAME
{{% /code-placeholder-key %}}: the name of the database to associate the LVC with - {{% code-placeholder-key %}}
AUTH_TOKEN
{{% /code-placeholder-key %}}: your {{< product-name >}} {{% show-in "enterprise" %}}admin {{% /show-in %}} authentication token - {{% code-placeholder-key %}}
TABLE_NAME
{{% /code-placeholder-key %}}: the name of the table to associate the LVC with {{% show-in "enterprise" %}} - {{% code-placeholder-key %}}
NODE_LIST
{{% /code-placeholder-key %}}: a comma-delimited list of node IDs to configure the LVC on--for example:node-01,node-02
. {{% /show-in %}} - {{% code-placeholder-key %}}
KEY_COLUMNS
{{% /code-placeholder-key %}}: a comma-delimited list of columns to use to unique identify each series--for example:room,wall
- {{% code-placeholder-key %}}
VALUE_COLUMNS
{{% /code-placeholder-key %}}: a comma-delimited list of columns to cache as value columns--for example:temp,hum,co
- {{% code-placeholder-key %}}
COUNT
{{% /code-placeholder-key %}}: the number of last values to cache per series--for example:5
- {{% code-placeholder-key %}}
TTL
{{% /code-placeholder-key %}}: the TTL of cached values in humantime form--for example:10s
,1min 30sec
,3 hours
- {{% code-placeholder-key %}}
LVC_NAME
{{% /code-placeholder-key %}}: a unique name for the LVC
The cache imports the distinct values from the table and starts caching them.
[!Important]
LVC size and persistence
The LVC is stored in memory, so it's important to consider the size and persistence of the cache. For more information, see Important things to know about the Last Value Cache.