memcache 1.0.0 → 1.0.1

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.
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 0
3
- :major: 1
2
+ :build:
4
3
  :minor: 0
4
+ :patch: 1
5
+ :major: 1
@@ -91,7 +91,7 @@ class Memcache
91
91
  end
92
92
 
93
93
  def set(key, value, opts = {})
94
- raise 'opts must be hash' unless opts.kind_of?(Hash)
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
- raise 'opts must be hash' unless opts.kind_of?(Hash)
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
- raise 'opts must be hash' unless opts.kind_of?(Hash)
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
 
@@ -5,14 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{memcache}
8
- s.version = "1.0.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.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
- - ext/extconf.rb
20
+ extensions: []
21
+
22
22
  extra_rdoc_files:
23
23
  - LICENSE
24
24
  - README.rdoc
@@ -1,3 +0,0 @@
1
- require 'mkmf'
2
- have_library('memcached')
3
- create_makefile('native_server')