summaryrefslogtreecommitdiff
path: root/src/stream.h
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2017-08-30 12:40:27 +0200
committerantirez <antirez@gmail.com>2017-12-01 10:24:24 +0100
commit79866a6361829ed0602dedff9cb378c66977227a (patch)
tree394042e4d08ba6563f674c87a314a045382d87c8 /src/stream.h
parent045d65c3af460a71d2b89b84f5e0b85d98320a77 (diff)
downloadredis-79866a6361829ed0602dedff9cb378c66977227a.tar.gz
Streams: 12 commits squashed into the initial Streams implementation.
Diffstat (limited to 'src/stream.h')
-rw-r--r--src/stream.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/stream.h b/src/stream.h
new file mode 100644
index 000000000..065c328eb
--- /dev/null
+++ b/src/stream.h
@@ -0,0 +1,21 @@
+#ifndef STREAM_H
+#define STREAM_H
+
+#include "rax.h"
+
+/* 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