Struct rustis::commands::TsCreateOptions
source · pub struct TsCreateOptions { /* private fields */ }
redis-time-series
only.Expand description
Options for the ts_add
command.
Implementations§
source§impl TsCreateOptions
impl TsCreateOptions
sourcepub fn retention(self, retention_period: u64) -> Self
pub fn retention(self, retention_period: u64) -> Self
maximum age for samples compared to the highest reported timestamp, in milliseconds.
Samples are expired based solely on the difference between their timestamp
and the timestamps passed to subsequent ts_add
,
ts_madd
, ts_incrby
,
and ts_decrby
calls.
When set to 0, samples never expire. When not specified, the option is set to the global
RETENTION_POLICY
configuration of the database, which by default is 0.
sourcepub fn encoding(self, encoding: TsEncoding) -> Self
pub fn encoding(self, encoding: TsEncoding) -> Self
specifies the series sample’s encoding format.
sourcepub fn chunk_size(self, chunk_size: usize) -> Self
pub fn chunk_size(self, chunk_size: usize) -> Self
initial allocation size, in bytes, for the data part of each new chunk. Actual chunks may consume more memory.
Changing chunkSize (using ts_alter
) does not affect existing chunks.
Must be a multiple of 8 in the range [48 .. 1048576]. When not specified, it is set to 4096 bytes (a single memory page).
Note: Before v1.6.10 no minimum was enforced. Between v1.6.10 and v1.6.17 and in v1.8.0 the minimum value was 128. Since v1.8.1 the minimum value is 48.
The data in each key is stored in chunks. Each chunk contains header and data for a given timeframe. An index contains all chunks. Iterations occur inside each chunk. Depending on your use case, consider these tradeoffs for having smaller or larger sizes of chunks:
- Insert performance: Smaller chunks result in slower inserts (more chunks need to be created).
- Query performance: Queries for a small subset when the chunks are very large are slower, as we need to iterate over the chunk to find the data.
- Larger chunks may take more memory when you have a very large number of keys and very few samples per key, or less memory when you have many samples per key.
If you are unsure about your use case, select the default.
sourcepub fn duplicate_policy(self, policy: TsDuplicatePolicy) -> Self
pub fn duplicate_policy(self, policy: TsDuplicatePolicy) -> Self
sourcepub fn labels<L: SingleArg, V: SingleArg, LL: KeyValueArgsCollection<L, V>>(
self,
labels: LL
) -> Self
pub fn labels<L: SingleArg, V: SingleArg, LL: KeyValueArgsCollection<L, V>>( self, labels: LL ) -> Self
set of label-value pairs that represent metadata labels of the time series.
Use it only if you are creating a new time series.
It is ignored if you are adding samples to an existing time series.
See labels
.
The ts_mget
, ts_mrange
,
and ts_mrevrange
commands operate on multiple time series based on their labels.
The ts_queryindex
command returns all time series keys matching a given filter based on their labels.