Module: Mcache

Defined in:
lib/mcache.rb,
lib/mcache/client.rb,
lib/mcache/config.rb,
lib/mcache/version.rb,
lib/mcache/connection.rb

Defined Under Namespace

Classes: Client, Config, Connection

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.configure(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mcache.rb', line 11

def self.configure(&block)
  @config = Mcache::Config.new
  @config.instance_eval &block if block_given?

  @connection = Mcache::Connection.new(
    @config.host,
    @config.pool_size,
    @config.timeout,
    @config.options
  )
end

.connectionObject



31
32
33
34
# File 'lib/mcache.rb', line 31

def self.connection
  configure unless @connection
  @connection
end

.fetch(key, options = {}) ⇒ Object



23
24
25
26
27
# File 'lib/mcache.rb', line 23

def self.fetch(key, options = {})
  Mcache::Client.new.fetch(key, options) do
    yield
  end
end