Skip to content

Commit

Permalink
Merge pull request #13 from TamarLabs/auto_id
Browse files Browse the repository at this point in the history
Auto
  • Loading branch information
daTokenizer committed Nov 25, 2016
2 parents ad0bf11 + f087c6a commit 1146c27
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ before_script:
- sudo pip install redis
- cd ..
- ./redis/src/redis-server --loadmodule ./module.so &
script: ./tests/test.py --noload
script: make test
50 changes: 42 additions & 8 deletions Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
### Commands described in this document

1. [`REDE.PUSH`](#push)
2. [`REDE.PULL`](#pull)
3. [`REDE.POLL`](#poll)
4. [`REDE.LOOK`](#look)
5. [`REDE.TTN`](#ttn)
6. [`REDE.UPDATE`](#update)
2. [`REDE.GIDPUSH`](#gidpush)
3. [`REDE.PULL`](#pull)
4. [`REDE.POLL`](#poll)
5. [`REDE.LOOK`](#look)
6. [`REDE.TTN`](#ttn)
7. [`REDE.UPDATE`](#update)

### Performance of commands in events/second by version
| Command | 0.1.0 | 0.2.* | 0.3.* |
Expand All @@ -19,7 +20,7 @@

## PUSH ##

*syntex:* **PUSH** dehydrator_name element_id element ttl
*syntex:* **PUSH** dehydrator_name ttl element element_id

*Available since: 0.1.0*

Expand All @@ -31,11 +32,11 @@ Note: if the key does not exist this command will create a Dehydrator on it.

***Return Value***

"OK" on success, Error if key is not a dehydrator, or element with `element_id` already exists.
"OK" on success, Error if key is not a dehydrator or if an element with `element_id` already exists.

Example
```
redis> REDE.PUSH my_dehydrator 101 "Dehydrate this" 3
redis> REDE.PUSH my_dehydrator 3 "Dehydrate this" 101
OK
redis> REDE.LOOK my_dehydrator 101
"Dehydrate this"
Expand All @@ -49,6 +50,39 @@ redis> REDE.POLL my_dehydrator
```


## GIDPUSH ##

*syntex:* **GIDPUSH** dehydrator_name ttl element

*Available since: 0.1.0*

*Time Complexity: O(1)*

Push an `element` into the dehydrator for `ttl` seconds, marking it with an *auto-generated* `element_id`
This command is slower then `PUSH` as the GUID generating process takes time.

Note: if the key does not exist this command will create a Dehydrator on it.

***Return Value***

The generated GUID on success, Error if key is not a dehydrator.

Example
```
redis> REDE.GIDPUSH my_dehydrator 3 "Dehydrate this"
SDDF126547398RTO2WC3SDFYEJU5HB
redis> REDE.LOOK my_dehydrator SDDF126547398RTO2WC3SDFYEJU5HB
"Dehydrate this"
redis> REDE.POLL my_dehydrator
(empty list or set)
```
wait for 3 seconds
```
redis> REDE.POLL my_dehydrator
"Dehydrate this"
```


## PULL ##

*syntex:* **PULL** dehydrator_name element_id
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ clean: FORCE
rm -rf ./$(SRC_DIR)/*.xo ./$(SRC_DIR)/*.so ./$(SRC_DIR)/*.o
rm -rf ./$(RMUTIL_LIBDIR)/*.so ./$(RMUTIL_LIBDIR)/*.o ./$(RMUTIL_LIBDIR)/*.a

test: FORCE
./tests/helloworld.py
./tests/test.py --noload

FORCE:
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ It can be found under the `rmutil` folder, and compiles into a static library yo

The dehydrator is an effective 'snooze button' for events, you push an event into it along with an id (for future referance) and in how many seconds you want it back, and poll whenever you want the elements back. only expired elements would pop out.

**The module include 6 main commands:**
**The module include 7 commands:**

* [`REDE.PUSH`](Commands.md/#push) - Insert an element, it will need an id, the element itself and dehydration time in seconds.
* [`REDE.PUSH`](Commands.md/#push) - Insert an element. The command takes an id for the element, the element itself and dehydration time in milliseconds.
* [`REDE.GIDPUSH`](Commands.md/#gidpush) - Insert an element. The command generates an id for the element, but still needs the element itself and dehydration time in milliseconds.
* [`REDE.PULL`](Commands.md/#pull) - Remove the element with the appropriate id before it expires.
* [`REDE.POLL`](Commands.md/#poll) - Pull and return all the expired elements.
* [`REDE.LOOK`](Commands.md/#look) - Search the dehydrator for an element with the given id and if found return it's payload (without pulling).
Expand Down Expand Up @@ -128,7 +129,6 @@ Enjoy!

## Future work

* Auto ID generation
* add some sort of pub/sub mechanism to POLL
* Additional / more thorough / automatic tests

Expand Down
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ <h2>

<p>The dehydrator is an effective 'snooze button' for events, you push an event into it along with an id (for future referance) and in how many seconds you want it back, and poll whenever you want the elements back. only expired elements would pop out.</p>

<p><strong>It includes 6 main commands:</strong></p>
<p><strong>It includes 7 commands:</strong></p>
* [`REDE.GIDPUSH`](Commands.md/#gidpush) -

<ul>
<li>
<a href="https://github.com/TamarLabs/ReDe/blob/master/Commands.md/#push"><code>REDE.PUSH</code></a> - Push an element, it will need an id, the element itself and dehydration time in seconds.</li>
<a href="https://github.com/TamarLabs/ReDe/blob/master/Commands.md/#push"><code>REDE.PUSH</code></a> - Insert an element. The command takes an id for the element, the element itself and dehydration time in milliseconds.</li>
<li>
<a href="https://github.com/TamarLabs/ReDe/blob/master/Commands.md/#gidpush"><code>REDE.GIDPUSH</code></a> - Insert an element. The command generates an id for the element, but still needs the element itself and dehydration time in milliseconds.</li>
<li>
<a href="https://github.com/TamarLabs/ReDe/blob/master/Commands.md/#pull"><code>REDE.PULL</code></a> - Pull the element with the appropriate id before it expires.</li>
<li>
Expand Down Expand Up @@ -164,7 +167,7 @@ <h2>
<img src="https://img.shields.io/travis/TamarLabs/ReDe/master.svg?style=flat-square"
alt="build status">
<span class="site-footer-owner"><a href="https://github.com/TamarLabs/ReDe">Rede</a> is maintained by <a href="https://github.com/TamarLabs">TamarLabs</a>.</span>

<span class="site-footer-credits">This page was partly generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span>
</footer>

Expand Down

0 comments on commit 1146c27

Please sign in to comment.