mshard 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/mshard/mshard.rb +10 -4
- data/lib/mshard/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a533debc16fe3c2f1dad4735b5bb6307b991c1a4bf79f7462112767566a21c9
|
4
|
+
data.tar.gz: 0f7c2af7de0c54fca819cb4da824508d5ce4f5aff94dd066cda03dbfc1f5efe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e193fdc0c040a628c4cce3d63a64c6980a450380c40a5c2a6e5baf6d5a23c6c8107d11623f8eb64269d5dd28eb536d6854271a768fae773cbee4497b78cc3e
|
7
|
+
data.tar.gz: 9b6e2efd1dd81a7d815b7d31a371688358c46eca53db08ab7258aa22465836316f7e3c8e6cebb8dbe77528ea43ace605b46fabb2b466fecca35fd70d98063f99
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mshard (0.7.
|
4
|
+
mshard (0.7.1)
|
5
5
|
hiredis
|
6
6
|
httparty
|
7
7
|
no_proxy_fix
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
guard (~> 2.0)
|
42
42
|
rubocop (~> 0.20)
|
43
43
|
hiredis (0.6.1)
|
44
|
-
httparty (0.16.
|
44
|
+
httparty (0.16.1)
|
45
45
|
multi_xml (>= 0.5.2)
|
46
46
|
json (2.1.0)
|
47
47
|
listen (3.1.5)
|
data/lib/mshard/mshard.rb
CHANGED
@@ -51,16 +51,22 @@ module MShard
|
|
51
51
|
Slack::Notifier.new(args[:webhook_url], **args).ping(args[:text])
|
52
52
|
end
|
53
53
|
|
54
|
+
def self.redis_cache(uri)
|
55
|
+
@cache ||= Hash.new do |hash, uri_|
|
56
|
+
hash[uri_] = Redis::Namespace.new(:shard, redis: Redis.new(url: uri_))
|
57
|
+
end
|
58
|
+
@cache[uri]
|
59
|
+
end
|
60
|
+
|
54
61
|
def load(id, redis_uri: ENV['MSHARD_REDIS_URI'])
|
55
62
|
return get(id) if detour? || redis_uri.nil?
|
56
|
-
|
57
|
-
redis.get(id)
|
63
|
+
self.class.redis_cache(redis_uri).get(id)
|
58
64
|
end
|
59
65
|
|
60
66
|
def save(redis_uri: ENV['MSHARD_REDIS_URI'], **args)
|
61
67
|
return set(**args) if detour? || redis_uri.nil?
|
62
|
-
|
63
|
-
|
68
|
+
response =
|
69
|
+
self.class.redis_cache(redis_uri).set(args[:id], args[:contents])
|
64
70
|
raise response unless response == 'OK'
|
65
71
|
args[:id]
|
66
72
|
end
|
data/lib/mshard/version.rb
CHANGED