Class: ActiveSupport::Cache::MemcacheConnectionPool
- Inherits:
-
Object
- Object
- ActiveSupport::Cache::MemcacheConnectionPool
- Defined in:
- lib/active_support/cache/memcache_connection_pool.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #async_connection_pool ⇒ Object
- #connection ⇒ Object
- #connection_pool ⇒ Object
- #decrement(name, amount = 1, options = nil) ⇒ Object
- #delete(name, options = nil) ⇒ Object
- #exist?(name, options = nil) ⇒ Boolean
- #fetch(name, options = nil) ⇒ Object
- #increment(name, amount = 1, options = nil) ⇒ Object
-
#initialize(options) ⇒ MemcacheConnectionPool
constructor
A new instance of MemcacheConnectionPool.
- #read(name, options = nil) ⇒ Object
- #read_multi(*names) ⇒ Object
- #reset(options = nil) ⇒ Object (also: #clear)
- #sync_connection_pool ⇒ Object
- #with_connection(&block) ⇒ Object
- #write(name, value, options = nil) ⇒ Object
Constructor Details
#initialize(options) ⇒ MemcacheConnectionPool
Returns a new instance of MemcacheConnectionPool.
6 7 8 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 6 def initialize() = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 4 def end |
Instance Method Details
#async_connection_pool ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 74 def async_connection_pool @async_connection_pool ||= begin spec = ActiveRecord::Base::ConnectionSpecification.new .merge(:async => true), ([:async_adapter_method] || [:adapter_method]) WithConnection::ConnectionPool.new [:name], spec end end |
#connection ⇒ Object
99 100 101 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 99 def connection connection_pool.connection end |
#connection_pool ⇒ Object
82 83 84 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 82 def connection_pool EM.reactor_running? ? async_connection_pool : sync_connection_pool end |
#decrement(name, amount = 1, options = nil) ⇒ Object
52 53 54 55 56 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 52 def decrement(name, amount = 1, =nil) with_connection do ? connection.decrement(name, amount, ) : connection.decrement(name, amount) end end |
#delete(name, options = nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 34 def delete(name, =nil) with_connection do ? connection.delete(name, ) : connection.delete(name) end end |
#exist?(name, options = nil) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 28 def exist?(name, =nil) with_connection do ? connection.exist?(name, ) : connection.exist?(name) end end |
#fetch(name, options = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 10 def fetch(name, =nil) with_connection do ? connection.fetch(name, ) : connection.fetch(name) end end |
#increment(name, amount = 1, options = nil) ⇒ Object
46 47 48 49 50 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 46 def increment(name, amount = 1, =nil) with_connection do ? connection.increment(name, amount, ) : connection.increment(name, amount) end end |
#read(name, options = nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 16 def read(name, =nil) with_connection do ? connection.read(name, ) : connection.read(name) end end |
#read_multi(*names) ⇒ Object
40 41 42 43 44 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 40 def read_multi(*names) with_connection do connection.read_multi *names end end |
#reset(options = nil) ⇒ Object Also known as: clear
58 59 60 61 62 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 58 def reset(=nil) with_connection do ? connection.reset() : connection.reset end end |
#sync_connection_pool ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 66 def sync_connection_pool @sync_connection_pool ||= begin spec = ActiveRecord::Base::ConnectionSpecification.new .dup, [:adapter_method] WithConnection::ConnectionPool.new [:name], spec end end |
#with_connection(&block) ⇒ Object
95 96 97 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 95 def with_connection(&block) connection_pool.with_connection(&block) end |
#write(name, value, options = nil) ⇒ Object
22 23 24 25 26 |
# File 'lib/active_support/cache/memcache_connection_pool.rb', line 22 def write(name, value, =nil) with_connection do ? connection.write(name, value, ) : connection.write(name, value) end end |