Skip to content

Commit

Permalink
some minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
daTokenizer committed Nov 17, 2016
1 parent 9dcaba8 commit b597857
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
6. [`REDE.UPDATE`](#update)

### Performance of commands in events/second by version
| Command | 0.1.0 | 0.2.* | *unstable* |
| Command | 0.1.0 | 0.2.* | 0.3.0 |
| ------------- |:------:|:-------:|:-------:|
| **PUSH** | 16,000 | 23,000 | 22,000 |
| **PULL** | 19,500 | 31,000 | 31,500 |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:rocket:**TL;DR - A Dehydrator is a fancy delayed queue, see what commands this module provides [HERE](Commands.md)**


**ReDe** /'redɪ/ *n.* a simple Redis Module for data dehydration. This is a pretty straightforward implementation of the dehydration system depicted in the article "[Fast Data](https://goo.gl/DDFFPO)". The Goal of this module is to solve the *Contextual Completeness* and *Emergent Relevancy* problems by adding the ability to postpone incoming elements to a later time in which we will have a complete information for these elements. Effectively acting as a snooze button to any element.
**ReDe** /'redɪ/ *n.* a Redis Module for simple data dehydration. This is a pretty straightforward implementation of the dehydration system depicted in the article "[Fast Data](https://goo.gl/DDFFPO)". The Goal of this module is to solve the *Contextual Completeness* and *Emergent Relevancy* problems by adding the ability to postpone incoming elements to a later time in which we will have a complete information for these elements. Effectively acting as a snooze button to any element.

From the article:
> Dehydrators are simplistic time machines. They transport data elements that arrived prematurely in terms of their context right to the future where they might be needed, without loading the system while waiting. This concept is achieved by attaching a time-indexed data store to a clock, storing elements as they arrive to the dehydrator and re-introducing them as inputs to the system once a predetermined time period has passed.
Expand Down
7 changes: 5 additions & 2 deletions module.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ int TimeToNextCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
return REDISMODULE_OK;
}

time_t now = time(0);
int time_to_next = -1;

khiter_t k;
Expand All @@ -567,7 +568,7 @@ int TimeToNextCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
ElementListNode* head = list->head;
if (head != NULL)
{
int tmp = head->expiration - time(0);
int tmp = head->expiration - now;
if (tmp <= 0)
{
time_to_next = 0;
Expand Down Expand Up @@ -784,6 +785,7 @@ int PollCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)

RedisModule_ReplyWithArray(ctx, REDISMODULE_POSTPONED_ARRAY_LEN);
int expired_element_num = 0;
time_t now = time(0);
// for each timeout_queue in timeout_queues
khiter_t k;
for (k = kh_begin(dehydrator->timeout_queues); k != kh_end(dehydrator->timeout_queues); ++k)
Expand All @@ -794,11 +796,12 @@ int PollCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
while ((list != NULL) && (!done_with_queue))
{
ElementListNode* head = list->head;
if ((head != NULL) && (head->expiration <= time(0)))
if ((head != NULL) && (head->expiration <= now))
{
ElementListNode* node = _listPop(list);
_removeNodeFromMapping(dehydrator, node);
RedisModule_ReplyWithString(ctx, node->element); // append node->element to output
deleteNode(node);
++expired_element_num;
}
else
Expand Down

0 comments on commit b597857

Please sign in to comment.