Class Merb::MemCacheSession
In: lib/merb-core/dispatch/session/memcached.rb
Parent: Object

Sessions stored in memcached.

Requires setup in your +init.rb+.

  require 'memcache'
  CACHE = MemCache.new('127.0.0.1:11211', { :namespace => 'my_app' })

And a setting in +init.rb+:

  c[:session_store] = 'memcache'

If you are using the memcached gem instead of memcache-client, you must setup like this:

  require 'memcached'
  CACHE = Memcached.new('127.0.0.1:11211', { :namespace => 'my_app' })

Methods

[]   []=   delete   each   generate   loaded?   new   persist   refresh_expiration   regenerate  

Attributes

data  [RW] 
needs_new_cookie  [RW] 
session_id  [RW] 

Public Class methods

Generates a new session ID and creates a new session.

Returns

MemCacheSession:The new session.

Parameters

session_id<String>:A unique identifier for this session.

Parameters

session_id<String:The ID of the session to retrieve.

Returns

Array:A pair consisting of a MemCacheSession and the session‘s ID. If no sessions matched session_id, a new MemCacheSession will be generated.

Public Instance methods

Parameters

k<~to_s>:The key of the session parameter to retrieve.

Returns

String:The value of the session parameter.

Parameters

k<~to_s>:The key of the session parameter to set.
v<~to_s>:The value of the session parameter to set.

Deletes the session by emptying stored data.

Yields the session data to an each block.

Parameter

&b:The block to pass to each.

Returns

Boolean:True if session has been loaded already.

Recreates the cookie with the default expiration time. Useful during log in for pushing back the expiration date.

Regenerate the session ID.

[Validate]