Create a Last Value Cache
Use the influxdb3 create last_cache
command
to create a Last Value Cache (LVC). Provide the following:
Database (
-d
,--database
): (Required) 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
): (Required) Your InfluxDB 3 Core authentication token. You can also use theINFLUXDB3_AUTH_TOKEN
environment variable to specify the token.Table (
-t
,--table
): (Required) The name of the table to associate the LVC with.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.
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
Replace the following:
DATABASE_NAME
: the name of the database to associate the LVC withAUTH_TOKEN
: your InfluxDB 3 Core authentication tokenTABLE_NAME
: the name of the table to associate the LVC withKEY_COLUMNS
: a comma-delimited list of columns to use to unique identify each series–for example:room,wall
VALUE_COLUMNS
: a comma-delimited list of columns to cache as value columns–for example:temp,hum,co
COUNT
: the number of last values to cache per series–for example:5
TTL
: the TTL of cached values in humantime form–for example:10s
,1min 30sec
,3 hours
LVC_NAME
: a unique name for the LVC
Values are cached on write
Values are cached on write. When you create a cache, it will not cache previously written points, only newly written points.
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.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB 3 Core and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.