Class: Taupe::Cache::MemcachedDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/taupe/cache/memcached.rb

Overview

Memcached cache driver

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dsn) ⇒ MemcachedDriver

Constructor

Parameters:

  • dsn (Hash)

    The data source name



15
16
17
# File 'lib/taupe/cache/memcached.rb', line 15

def initialize(dsn)
  @connection = Memcached.new dsn
end

Instance Attribute Details

#connectionObject

Accessors



11
12
13
# File 'lib/taupe/cache/memcached.rb', line 11

def connection
  @connection
end

Instance Method Details

#delete(key) ⇒ Object

Delete a key

Parameters:

  • key (String)

    The key to delete



35
36
37
# File 'lib/taupe/cache/memcached.rb', line 35

def delete(key)
  @connection.delete key.to_s
end

#get(key) ⇒ Object

Get a cache entry

Parameters:

  • key (String)

    The key to retrieve

Returns:

  • (Object)


22
23
24
# File 'lib/taupe/cache/memcached.rb', line 22

def get(key)
  @connection.get key.to_s
end

#set(key, value) ⇒ Object

Set a cache entry

Parameters:

  • key (String)

    The key to set

  • value (Object)

    The value



29
30
31
# File 'lib/taupe/cache/memcached.rb', line 29

def set(key, value)
  @connection.set key.to_s, value
end