Table of contents
1.
Introduction
2.
Client Libraries
3.
Memory Model
4.
Forum
5.
License
6.
Commands for Time Series
6.1.
TS.ADD
6.2.
TS. CREATE
6.3.
TS.CREATERULE
6.4.
TS.DEL
6.5.
TS.GET
6.6.
TS.INFO
6.7.
TS.MADD
6.8.
TS.DELETERULE
6.9.
TS.MRANGE
7.
Frequently Asked Questions
7.1.
What is the purpose of TS.GET command?
7.2.
What is the purpose of TS.ADD command?
7.3.
Define the basis of TS.DEL command?
7.4.
Which command is used to delete a compaction rule?
7.5.
Which command is used to create a compaction rule?
8.
Conclusion
Last Updated: Mar 27, 2024

Commands for the Time Series in Redis

Author Prachi Singh
0 upvote

Introduction

Redis Time Series is a module that adds Time Series structure to the Redis. The various features of this module are listed below.

  • Insertion of high volume
  • Queries listed from the start time to end time
  • Aggregate Queries from any time bucket
  • Downsampling
  • Available with Secondary Indexing

Client Libraries

Client Libraries are categorized as official and community in Python, Java, Ruby, Javascript, and PHP.

Memory Model

A time series is also referred to as the linked list of memory chunks. Each chunk further consists of a predefined size of samples. Each sample consists of 128 bit Tuple. 

Forum

In case of any queries, users can clear their doubts at the Redis TimeSeries mailing list.

License

Redis Source Available License Agreement at LICENSE.

Commands for Time Series

TS.ADD

This command is used to append a sample to a time series.

TS.ADD key timestamp value [RETENTION retentionPeriod] [ENCODING [COMPRESSED|UNCOMPRESSED]] [CHUNK_SIZE size] [ON_DUPLICATE policy] [LABELS {label value}...

TS. CREATE

This command is used to create a new time series.

TS.CREATE key [RETENTION retentionPeriod] [ENCODING [UNCOMPRESSED|COMPRESSED]] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [LABELS {label value}...]

TS.CREATERULE

This command is used to create a compaction rule.

TS.CREATERULE sourceKey destKey AGGREGATION aggregator bucketDuration [alignTimestamp]

TS.DEL

This command is used to delete all samples between two given timestamps.

TS.DEL key fromTimestamp toTimestamp

TS.GET

This command is used to get the last sample.

TS.GET key

TS.INFO

This command returns the information regarding the statistics of a given time series.

TS.INFO key [DEBUG]

TS.MADD

This command is used to append a sample to two or more time series.

TS.MADD {key timestamp value}...

TS.DELETERULE

This command is used to delete a compaction rule.

TS.DELETERULE sourceKey destKey

TS.MRANGE

This command is used to query a range in multiple time series in the forward direction.

TS.MRANGE fromTimestamp toTimestamp
          [FILTER_BY_TS TS...]
          [FILTER_BY_VALUE min max]
          [WITHLABELS | SELECTED_LABELS label...]
          [COUNT count]
          [[ALIGN value] AGGREGATION aggregator bucketDuration [BUCKETTIMESTAMP bt] [EMPTY]]
          FILTER filter..
          [GROUPBY label REDUCE reducer]

Frequently Asked Questions

What is the purpose of TS.GET command?

This command is used to get the last sample.

What is the purpose of TS.ADD command?

This command is used to append a sample to a time series.

Define the basis of TS.DEL command?

This command is used to delete all samples between two given timestamps.

Which command is used to delete a compaction rule?

TS.DELETERULE

Which command is used to create a compaction rule?

TS.CREATERULE

Conclusion

After reading about  Time Series Commands are you not feeling excited to read/explore more articles on Commands? Don't worry; Coding Ninjas has you covered.

However, you may want to pursue our premium courses to give your job an advantage over the competition!

With our Coding Ninjas Studio Guided Path, you may learn about Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and more! Check out the mock test series and participate in the contests on Coding Ninjas Studio if you want to put your coding talents to the test! However, if you've just started school and are looking for answers to concerns raised by digital behemoths such as Amazon, Microsoft, Uber, and others. As part of your placement preparations, you must evaluate the obstaclesinterview experiences, and interview package in this case. Please vote for our blogs if you find them valuable and exciting.

Happy studying!!

Live masterclass