redislike 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.org +105 -0
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
- data/README.md +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9e7d2af78acf470ff2ce2935846897c3a51265b0cffa5cf1c4ca1fae7e6badf
|
4
|
+
data.tar.gz: cfcb15d58d797496e28259aadfc9c610d3ceab11f3ff8d58910d248918bc424c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b5bd69eb2ad93051d3c07bd3d7db65b5c5c8352dd6b282822dd41e4c7b55690388a4619a4c1429419db475c7b937ef3f0be7b078645bea5e01ff9fb8eae4ff
|
7
|
+
data.tar.gz: ab010af0e79aece8a0ab5b17cf2fd7725574dd1e4feb827a3c82e562aabd3305e7723a2437026f6d4df8cff9a729227e93555b3946cda3260712f12b0c5e3394
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/README.org
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#+TITLE: redislike - redis-like list operations for moneta
|
2
|
+
#+LATEX: \pagebreak
|
3
|
+
|
4
|
+
* Overview
|
5
|
+
|
6
|
+
~redislike~ adds backend-independent support for redis-like list operations to
|
7
|
+
any Moneta datastore.
|
8
|
+
|
9
|
+
* Supported Operations
|
10
|
+
|
11
|
+
- BLPOP
|
12
|
+
- BRPOP
|
13
|
+
- BRPOPLPUSH
|
14
|
+
- LINDEX
|
15
|
+
- LINSERT
|
16
|
+
- LLEN
|
17
|
+
- LPOP
|
18
|
+
- LPUSH
|
19
|
+
- LPUSHX
|
20
|
+
- LRANGE
|
21
|
+
- LREM
|
22
|
+
- LSET
|
23
|
+
- LTRIM
|
24
|
+
- RPOP
|
25
|
+
- RPOPLPUSH
|
26
|
+
- RPUSH
|
27
|
+
- RPUSHX
|
28
|
+
|
29
|
+
* Other Supported Operations
|
30
|
+
|
31
|
+
- EXISTS
|
32
|
+
|
33
|
+
* Differences from Redis
|
34
|
+
|
35
|
+
- LSET with a non-existent list raises a =KeyError= rather than a =Redis::CommandError=.
|
36
|
+
- LSET with an out of range index raises an =IndexError= rather than a =Redis::CommandError=.
|
37
|
+
|
38
|
+
* Installation
|
39
|
+
|
40
|
+
#+BEGIN_SRC shell
|
41
|
+
gem install redislike
|
42
|
+
#+END_SRC
|
43
|
+
|
44
|
+
* Example
|
45
|
+
|
46
|
+
#+BEGIN_SRC ruby
|
47
|
+
require 'redislike'
|
48
|
+
datastore = Moneta.new :Memory, expires: true
|
49
|
+
|
50
|
+
datastore.lpush 'pending', 'foo'
|
51
|
+
datastore.rpoplpush 'pending', 'active'
|
52
|
+
puts datastore.lrange 'active', 0, -1
|
53
|
+
#+END_SRC
|
54
|
+
|
55
|
+
Returns =['foo']=
|
56
|
+
|
57
|
+
* Motivation
|
58
|
+
|
59
|
+
Redis may be my favourite data store, for a number of reasons that have
|
60
|
+
nothing to do with this gem. It's also not a silver bullet. Like many tools,
|
61
|
+
used in the right context, it excels. Out of its element, it adds complexity
|
62
|
+
and overhead (when compared to using a tool better suited to that problem
|
63
|
+
domain).
|
64
|
+
|
65
|
+
Then there's Moneta, a lovely gem that provides a unified API to an impressive
|
66
|
+
range of backends for key/value storage. This allows low-effort integration
|
67
|
+
with whatever data store you already have. The consistency also enables
|
68
|
+
trivial swapping of backends as the evolution of an application guides
|
69
|
+
requirements, without rewriting much of anything.
|
70
|
+
|
71
|
+
To achive this consistency, Moneta omits support for backend-specfic features.
|
72
|
+
One of those that I often want is the (B)RPOPLPUSH list operation from Redis.
|
73
|
+
This takes an item from the tail of one list, and puts it at the head of
|
74
|
+
another list.
|
75
|
+
|
76
|
+
Rather than depending on a Redis backend for Moneta, and passing these
|
77
|
+
operations through to it, I built redis-like queue operations on top of
|
78
|
+
Moneta. Once those were in place, it seemed reasonable to continue and build
|
79
|
+
the rest.
|
80
|
+
|
81
|
+
At this point, some sort of scope began to take shape. The methods were
|
82
|
+
restructured to align with those provided by Redis, and tests were written to
|
83
|
+
guide this process.
|
84
|
+
|
85
|
+
**TL;DR: I wanted RPOPLPUSH in Moneta, didn't define scope boundaries and
|
86
|
+
accidentally reimplemented (some of) Redis.**
|
87
|
+
|
88
|
+
* What's up with the tests?
|
89
|
+
|
90
|
+
Alright, so the tests are a bit unconventional, in the sense that you need a
|
91
|
+
working redis server to actually run the tests for a gem with the stated
|
92
|
+
intent of not requiring a redis server.
|
93
|
+
|
94
|
+
These tests that redislike is in fact, redis-like. These work by executing the
|
95
|
+
same instructions against redis, and an in-memory instance of redislike, and
|
96
|
+
asserting that the results should be the same.
|
97
|
+
|
98
|
+
* License
|
99
|
+
|
100
|
+
~redislike~ is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See ~LICENSE.txt~ for the full
|
101
|
+
text.
|
102
|
+
|
103
|
+
* Contributors
|
104
|
+
|
105
|
+
- [[https://colstrom.github.io/][Chris Olstrom]] | [[mailto:chris@olstrom.com][e-mail]] | [[https://twitter.com/ChrisOlstrom][Twitter]]
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redislike
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Olstrom
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
EIKh6yDoB+oCRuiTV0uw/lKE2PtbONhJb7uN1qhZqla/iBpmUjiEu8+skI+ygv9n
|
35
35
|
7Krw8FJrV3+VRCiZTPKHeshAfL9yeIZh
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2018-03-
|
37
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: moneta
|
@@ -66,7 +66,7 @@ files:
|
|
66
66
|
- ".gitignore"
|
67
67
|
- Gemfile
|
68
68
|
- LICENSE.txt
|
69
|
-
- README.
|
69
|
+
- README.org
|
70
70
|
- Rakefile
|
71
71
|
- lib/redislike.rb
|
72
72
|
- lib/redislike/helpers/lists.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.md
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
redislike
|
2
|
-
=========
|
3
|
-
|
4
|
-
For when we want Redis, but can't have nice things.
|
5
|
-
|
6
|
-
redislike adds backend-independent support for redis-like list operations to any Moneta datastore.
|
7
|
-
|
8
|
-
Supported Operations
|
9
|
-
--------------------
|
10
|
-
* BLPOP
|
11
|
-
* BRPOP
|
12
|
-
* BRPOPLPUSH
|
13
|
-
* LINDEX
|
14
|
-
* LINSERT
|
15
|
-
* LLEN
|
16
|
-
* LPOP
|
17
|
-
* LPUSH
|
18
|
-
* LPUSHX
|
19
|
-
* LRANGE
|
20
|
-
* LREM
|
21
|
-
* LSET
|
22
|
-
* LTRIM
|
23
|
-
* RPOP
|
24
|
-
* RPOPLPUSH
|
25
|
-
* RPUSH
|
26
|
-
* RPUSHX
|
27
|
-
|
28
|
-
Other Supported Operations
|
29
|
-
--------------------------
|
30
|
-
* EXISTS
|
31
|
-
|
32
|
-
Differences from Redis
|
33
|
-
----------------------
|
34
|
-
* LSET with a non-existent list raises a ```KeyError``` rather than a ```Redis::CommandError```.
|
35
|
-
* LSET with an out of range index raises an ```IndexError``` rather than a ```Redis::CommandError```.
|
36
|
-
|
37
|
-
Installation
|
38
|
-
------------
|
39
|
-
|
40
|
-
```gem install redislike```
|
41
|
-
|
42
|
-
or in your Gemfile
|
43
|
-
|
44
|
-
```gem 'redislike'```
|
45
|
-
|
46
|
-
Example
|
47
|
-
-----
|
48
|
-
|
49
|
-
```
|
50
|
-
require 'redislike'
|
51
|
-
datastore = Moneta.new :Memory, expires: true
|
52
|
-
|
53
|
-
datastore.lpush 'pending', 'foo'
|
54
|
-
datastore.rpoplpush 'pending', 'active'
|
55
|
-
puts datastore.lrange 'active', 0, -1
|
56
|
-
```
|
57
|
-
|
58
|
-
Should return ```['foo']```
|
59
|
-
|
60
|
-
Motivation
|
61
|
-
----------
|
62
|
-
|
63
|
-
Redis may be my favourite data store, for a number of reasons that have nothing to do with this gem. It's also not a silver bullet. Like many tools, used in the right context, it excels. Out of its element, it adds complexity and overhead (when compared to using a tool better suited to that problem domain).
|
64
|
-
|
65
|
-
Then there's Moneta, a lovely gem that provides a unified API to an impressive range of backends for key/value storage. This allows low-effort integration with whatever data store you already have. The consistency also enables trivial swapping of backends as the evolution of an application guides requirements, without rewriting much of anything.
|
66
|
-
|
67
|
-
To achive this consistency, Moneta omits support for backend-specfic features. One of those that I often want is the (B)RPOPLPUSH list operation from Redis. This takes an item from the tail of one list, and puts it at the head of another list.
|
68
|
-
|
69
|
-
Rather than depending on a Redis backend for Moneta, and passing these operations through to it, I built redis-like queue operations on top of Moneta. Once those were in place, it seemed reasonable to continue and build the rest.
|
70
|
-
|
71
|
-
At this point, some sort of scope began to take shape. The methods were restructured to align with those provided by Redis, and tests were written to guide this process.
|
72
|
-
|
73
|
-
**TL;DR: I wanted RPOPLPUSH in Moneta, didn't define scope boundaries and accidentally reimplemented (some of) Redis.**
|
74
|
-
|
75
|
-
Dependencies
|
76
|
-
------------
|
77
|
-
* Moneta
|
78
|
-
|
79
|
-
What's up with the tests?
|
80
|
-
-------------------------
|
81
|
-
|
82
|
-
Alright, so the tests are a bit unconventional, in the sense that you need a working redis server to actually run the tests for a gem with the stated intent of not requiring a redis server.
|
83
|
-
|
84
|
-
These tests that redislike is in fact, redis-like. These work by executing the same instructions against redis, and an in-memory instance of redislike, and asserting that the results should be the same.
|