redic 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -6
- data/lib/redic/client.rb +1 -11
- data/redic.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bbf2e9c0a04c38c2fedc078ec27d1f92f5c6d4d
|
4
|
+
data.tar.gz: 9e58dc7004c43eceee2d4207551bd48aad7ecebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89892ba684ac2c9ca56d433feadf3871d3dd89a541e850fe717bf9c067e6e0d84730f73f7e9d7dfde5b3ca950ef173a22c461356eedf7e4a5c09abab101bd1d7
|
7
|
+
data.tar.gz: 268b97ee191a5092dc63ca8658cc5af6eaf66ebf75413119e7255643300934c0554ca18bcf592c2f64d15927264b7813c70d98a8a81031866bf37c21b51779a5
|
data/README.md
CHANGED
@@ -6,9 +6,8 @@ Lightweight Redis Client
|
|
6
6
|
Description
|
7
7
|
-----------
|
8
8
|
|
9
|
-
Lightweight Redis Client inspired by
|
10
|
-
|
11
|
-
library for golang.
|
9
|
+
Lightweight Redis Client inspired by [redigo][redigo], a Redis
|
10
|
+
client library for golang.
|
12
11
|
|
13
12
|
## Usage
|
14
13
|
|
@@ -23,10 +22,10 @@ assert_equal "bar", redis.call("GET", "foo")
|
|
23
22
|
|
24
23
|
# Pipelining is implemented by buffering commands,
|
25
24
|
# then calling Redic#run
|
26
|
-
redis.
|
27
|
-
redis.
|
25
|
+
redis.queue("SET", "foo", "bar")
|
26
|
+
redis.queue("GET", "foo")
|
28
27
|
|
29
|
-
assert_equal ["OK", "bar"], redis.
|
28
|
+
assert_equal ["OK", "bar"], redis.commit
|
30
29
|
```
|
31
30
|
|
32
31
|
## Differences with redis-rb
|
@@ -39,6 +38,10 @@ than that of redis-rb, as it only wraps the writing and reading from
|
|
39
38
|
the connection. So even if both clients are thread-safe by default,
|
40
39
|
the peformance of a smaller lock is marginally better.
|
41
40
|
|
41
|
+
[redigo]: https://github.com/garyburd/redigo
|
42
|
+
[hiredis]: https://github.com/pietern/hiredis-rb
|
43
|
+
[redis-rb]: https://github.com/redis/redis-rb
|
44
|
+
|
42
45
|
## Limitations
|
43
46
|
|
44
47
|
When a client enters a subscribed mode, further reads to retrieve the
|
data/lib/redic/client.rb
CHANGED
@@ -5,7 +5,6 @@ class Redic
|
|
5
5
|
class Client
|
6
6
|
def initialize(url)
|
7
7
|
@uri = URI.parse(url)
|
8
|
-
@ttl = Integer(ENV.fetch("REDIC_TTL", 60))
|
9
8
|
@connection = nil
|
10
9
|
@semaphore = Mutex.new
|
11
10
|
end
|
@@ -20,7 +19,6 @@ class Redic
|
|
20
19
|
|
21
20
|
def connect
|
22
21
|
establish_connection unless connected?
|
23
|
-
timestamp_connection
|
24
22
|
|
25
23
|
@semaphore.synchronize do
|
26
24
|
yield
|
@@ -41,10 +39,6 @@ class Redic
|
|
41
39
|
authenticate
|
42
40
|
end
|
43
41
|
|
44
|
-
def timestamp_connection
|
45
|
-
@timestamp = Time.now.to_i
|
46
|
-
end
|
47
|
-
|
48
42
|
def authenticate
|
49
43
|
if @uri.password
|
50
44
|
@semaphore.synchronize do
|
@@ -55,11 +49,7 @@ class Redic
|
|
55
49
|
end
|
56
50
|
|
57
51
|
def connected?
|
58
|
-
@connection && @connection.connected?
|
59
|
-
end
|
60
|
-
|
61
|
-
def alive?
|
62
|
-
Time.now.to_i - @timestamp < @ttl
|
52
|
+
@connection && @connection.connected?
|
63
53
|
end
|
64
54
|
end
|
65
55
|
end
|
data/redic.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hiredis
|