Documentation

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 the INFLUXDB3_DATABASE_NAME environment variable to specify the database.

  • Token (--token): (Required) Your InfluxDB 3 Core authentication token. You can also use the INFLUXDB3_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 is 1.

  • 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
  • Copy
  • Fill window

Replace the following:

  • DATABASE_NAME: the name of the database to associate the LVC with

  • AUTH_TOKEN: your InfluxDB 3 Core authentication token

  • TABLE_NAME: the name of the table to associate the LVC with

  • KEY_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!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

Now Generally Available

InfluxDB 3 Core and Enterprise

Start fast. Scale faster.

Get the Updates

InfluxDB 3 Core is an open source, high-speed, recent-data engine that collects and processes data in real-time and persists it to local disk or object storage. InfluxDB 3 Enterprise builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries and optimized storage. A free tier of InfluxDB 3 Enterprise is available for non-commercial at-home or hobbyist use.

For more information, check out: