2017-08-30 06:40:27 -04:00
|
|
|
#ifndef STREAM_H
|
|
|
|
#define STREAM_H
|
|
|
|
|
|
|
|
#include "rax.h"
|
2017-09-05 07:14:13 -04:00
|
|
|
#include "listpack.h"
|
2017-08-30 06:40:27 -04:00
|
|
|
|
|
|
|
/* Stream item ID: a 128 bit number composed of a milliseconds time and
|
|
|
|
* a sequence counter. IDs generated in the same millisecond (or in a past
|
|
|
|
* millisecond if the clock jumped backward) will use the millisecond time
|
|
|
|
* of the latest generated ID and an incremented sequence. */
|
|
|
|
typedef struct streamID {
|
|
|
|
uint64_t ms; /* Unix time in milliseconds. */
|
|
|
|
uint64_t seq; /* Sequence number. */
|
|
|
|
} streamID;
|
|
|
|
|
|
|
|
typedef struct stream {
|
|
|
|
rax *rax; /* The radix tree holding the stream. */
|
|
|
|
uint64_t length; /* Number of elements inside this stream. */
|
|
|
|
streamID last_id; /* Zero if there are yet no items. */
|
|
|
|
} stream;
|
|
|
|
|
|
|
|
#endif
|