simple_cache_rs 0.10.1 → 0.10.2
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.
- data/lib/simple_cache.rb +17 -13
- metadata +2 -2
data/lib/simple_cache.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "uri"
|
2
|
+
require "expectation"
|
2
3
|
|
3
4
|
module SimpleCache
|
4
5
|
end
|
@@ -8,23 +9,26 @@ require_relative "simple_cache/sqlite_store"
|
|
8
9
|
require_relative "simple_cache/redis_store"
|
9
10
|
|
10
11
|
module SimpleCache
|
11
|
-
def self.
|
12
|
+
def self.create_store(url)
|
13
|
+
expect! url => [ String, Redis, Redis::Namespace ]
|
12
14
|
case url
|
13
15
|
when Redis, Redis::Namespace then
|
14
16
|
return SimpleCache::RedisStore.new(url)
|
17
|
+
when String
|
18
|
+
uri = URI.parse(url)
|
19
|
+
|
20
|
+
case uri.scheme
|
21
|
+
when "redis" then
|
22
|
+
return SimpleCache::RedisStore.new(url)
|
23
|
+
when nil, "sqlite" then
|
24
|
+
return SimpleCache::SqliteStore.new(uri.path)
|
25
|
+
else raise uri.scheme.inspect
|
26
|
+
end
|
15
27
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when "redis" then
|
21
|
-
SimpleCache::RedisStore.new(url)
|
22
|
-
when nil, "sqlite" then
|
23
|
-
SimpleCache::SqliteStore.new(uri.path)
|
24
|
-
else raise uri.scheme.inspect
|
25
|
-
end
|
26
|
-
|
27
|
-
cache.extend SimpleCache::Interface
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.new(url)
|
31
|
+
create_store(url).extend SimpleCache::Interface
|
28
32
|
end
|
29
33
|
|
30
34
|
singleton_class.class_eval do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_cache_rs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -41,7 +41,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
41
|
version: '0'
|
42
42
|
segments:
|
43
43
|
- 0
|
44
|
-
hash: -
|
44
|
+
hash: -2541053679454630018
|
45
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
46
|
none: false
|
47
47
|
requirements:
|