Documentation for python-stdnet's DEVELOPMENT version. Get the release docs here.

Warning

This branch is not longer active. Both the *ZDIFFSTORE* command and the
*timeseries* data-structure have been implemented using lua scripts.
If timeseries is what you are looking for, check the
*timeseries data structure* for
univariate timeseries and the *column timeseries* for
numeric multivariate timeseries suitable for modelling financial timeseries.
Stdnet uses redis >= 2.6 from the standard (antirez) distribution.

During the development of stdnet we came across several design decisions, some more critical than others, and most of them were resolved coding the client only. However, more exotic features, such as the time series structure, required hacking on the server side.

For this reason we have the stdnet-redis branch.

For some reasons redis does not have a `zdiffstore` command.
For 99% of applications this is not an issue, but when using stdnet with
models which have an *implicit sorting* it becomes one.

Computes the difference between the first sorted set and all the successive sorted sets given by the specified keys, and stores the result in destination. It is mandatory to provide the number of input keys (numkeys) before passing the input keys and the other (optional) arguments:

`ZDIFFSTORE destination numkeys key [key ...] [withscore]`

If the optional argument `withscore` is `True` (default is `False`), elements are
removed from the first sorted sets only if the score is matched.

Time-series is an important data-structure not yet supported in redis, it is represented by a unique sorted associative container, that is to say it associates ordered unique times to values.

Values, which can be anything you like, are ordered with respect to times (you could use unix timestamp, but any double value would do), and can be accessed by times or rank (the order of times in the time-series). Times are unique so that there will be only one value associated with a given time.

Internally, a time-series is implemented using the same skiplist implementation as ordered sets. Values are added to a skip list which maintain sorting with respect to times.

Performance:

`O(log(N)) on INSERT REMOVE and RETRIEVAL via times`

There are currently seven commands which cover the basic operations of a timeseries. I tried to keep them to a minimum but there is scope to add more.

Add items to timeseries at `key`:

`tsadd key time1 value1 time2 value2 ...`

If value at `time` is already available, the value will be updated.

Range by rank:

`tsrange key start end <flag>`

Where `start` and `end` are integers following the same
Redis conventions as `zrange`, `<flag>` is an optional
string which can take two values: `withtimes` or `novalues`:

```
tsrange key start end -> return values
tsrange key start end withtimes -> return (time,value)s
tsrange key start end novalues -> return times
```

Range by times:

`tsrangebytime key time_start time_end <flag>`

Where `time_start` and `time_end` are double (timestaps) and `<flag>`
is the same as in `TSRANGE`.

- Added 2 files in
`src`:`t_ts.h`and`t_ts.c`. - Modified
`redis.c`to add extra commands to the command table and added the`t_ts.h`include. - Modified
`Makefile`so that`t_ts.c`is compiled. - Modified
`object.c`in`decrRefCount`and added`t_ts.h`include. - Modified
`db.c`in`typeCommand`and added`t_ts.h`include. - Modified
`rdb.c`in`rdbSaveObject`and`rdbLoadObject`and added`t_ts.h`include.

- Modified so that
`t_ts.c`can use its internals. - Modified
`zunionInterGenericCommand`function to accommodate the ZDIFFSTORE command.