memcache 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +3 -2
- data/lib/memcache.rb +30 -3
- data/memcache.gemspec +1 -2
- metadata +3 -3
- data/ext/extconf.rb +0 -3
data/VERSION.yml
CHANGED
data/lib/memcache.rb
CHANGED
@@ -91,7 +91,7 @@ class Memcache
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def set(key, value, opts = {})
|
94
|
-
|
94
|
+
opts = compatible_opts(opts)
|
95
95
|
|
96
96
|
expiry = opts[:expiry] || default_expiry
|
97
97
|
flags = opts[:flags] || 0
|
@@ -106,7 +106,7 @@ class Memcache
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def add(key, value, opts = {})
|
109
|
-
|
109
|
+
opts = compatible_opts(opts)
|
110
110
|
|
111
111
|
expiry = opts[:expiry] || default_expiry
|
112
112
|
flags = opts[:flags] || 0
|
@@ -116,7 +116,7 @@ class Memcache
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def replace(key, value, opts = {})
|
119
|
-
|
119
|
+
opts = compatible_opts(opts)
|
120
120
|
|
121
121
|
expiry = opts[:expiry] || default_expiry
|
122
122
|
flags = opts[:flags] || 0
|
@@ -281,8 +281,35 @@ class Memcache
|
|
281
281
|
set(key, value)
|
282
282
|
end
|
283
283
|
|
284
|
+
def self.init(yaml_file = nil)
|
285
|
+
yaml_file = File.join(Rails.root, 'config', 'memcached.yml')
|
286
|
+
|
287
|
+
if File.exists?(yaml_file)
|
288
|
+
yaml = YAML.load_file(yaml_file)
|
289
|
+
defaults = (yaml.delete('defaults') || {}).symbolize_keys
|
290
|
+
config = (yaml[Rails.env] || {}).symbolize_keys
|
291
|
+
|
292
|
+
if not config.empty? and not config[:disabled]
|
293
|
+
if config[:servers]
|
294
|
+
opts = defaults.merge(config.symbolize_keys)
|
295
|
+
Object.const_set('CACHE', Memcache.new(opts))
|
296
|
+
else
|
297
|
+
config.each do |connection, opts|
|
298
|
+
opts = defaults.merge(opts.symbolize_keys)
|
299
|
+
Memcache.pool[connection] = Memcache.new(opts)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
284
306
|
protected
|
285
307
|
|
308
|
+
def compatible_opts(opts)
|
309
|
+
# Support passing expiry instead of opts. This may be deprecated in the future.
|
310
|
+
opts.kind_of?(Hash) ? opts : {:expiry => opts}
|
311
|
+
end
|
312
|
+
|
286
313
|
def multi_get(keys, opts = {})
|
287
314
|
return {} if keys.empty?
|
288
315
|
|
data/memcache.gemspec
CHANGED
@@ -5,14 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{memcache}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Balthrop"]
|
12
12
|
s.date = %q{2009-11-20}
|
13
13
|
s.description = %q{Ruby client for memcached supporting advanced protocol features and pluggable architecture.}
|
14
14
|
s.email = %q{code@justinbalthrop.com}
|
15
|
-
s.extensions = ["ext/extconf.rb"]
|
16
15
|
s.extra_rdoc_files = [
|
17
16
|
"LICENSE",
|
18
17
|
"README.rdoc"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memcache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Balthrop
|
@@ -17,8 +17,8 @@ description: Ruby client for memcached supporting advanced protocol features and
|
|
17
17
|
email: code@justinbalthrop.com
|
18
18
|
executables: []
|
19
19
|
|
20
|
-
extensions:
|
21
|
-
|
20
|
+
extensions: []
|
21
|
+
|
22
22
|
extra_rdoc_files:
|
23
23
|
- LICENSE
|
24
24
|
- README.rdoc
|
data/ext/extconf.rb
DELETED