TSADD

    • If the given timestamp already exists in the specified time series, this command overwrites the existing value with the given value.
    • If the given key does not exist, a new time series is created for the key, and the given values are inserted to the associated given fields.
    • If the given exists, but is not of time series type, an error is raised.
    • EXPIRE_IN TTL sets the TTL (time-to-live) in seconds for the entries being added.
    • EXPIRE_AT UNIX_TIMESTAMP ensures that the entries added would expire by the given UNIX_TIMESTAMP (seconds since January 1, 1970).

    Returns the appropriate status string.

    1. "OK"
    1. $ TSADD cpu_usage 20 "80" 30 "60" 40 "90"
    1. "OK"

    We could also encode the timestamp as “yyyymmddhhmm”, since this would still produce integers that are sortable by the actual timestamp.

    1. $ TSADD cpu_usage 201710311100 "50"
    1. "OK"
      1. $ TSGET cpu_usage 10
      1. $ TSGET cpu_usage 201710311100
      1. "50"
      1. "75"

      Set a TTL of 3600 seconds (1 hour) for an entry that we add.

      1. $ TSADD cpu_usage 60 "70" EXPIRE_IN 3600
      1. "OK"
        1. "OK"

        , tsget, ,tsrevrangebytime, , tscard