class MemcacheSessionHandler implements SessionHandlerInterface (View source)

A session handler interface using the GAE Memcache API.

Constants

SESSION_PREFIX

Methods

__construct(MemcacheContainer $memcacheContainer = null)

Constructs the session handler instance.

bool
open(string $savePath, string $sessionName)

Opens the session handler.

bool
close()

Closes the session handler.

string
read(string $id)

Read an element from Memcache with the given ID.

bool
write(string $id, string $data)

Write an element to Memcache with the given ID and data.

bool
destroy(string $id)

Destroy the data associated with a particular session ID.

bool
gc(int $maxlifetime)

Garbage collection method - always returns true as this is handled by the Memcache expire function.

static 
configure(MemcacheContainer $memcacheContainer = null)

Configure the session handler to use the Memcache API.

Details

__construct(MemcacheContainer $memcacheContainer = null)

Constructs the session handler instance.

Parameters

MemcacheContainer $memcacheContainer Optional, for mocking in tests

bool open(string $savePath, string $sessionName)

Opens the session handler.

Parameters

string $savePath Not used
string $sessionName Not ued

Return Value

bool true if successful, false otherwise

bool close()

Closes the session handler.

Return Value

bool true if successful, false otherwise

string read(string $id)

Read an element from Memcache with the given ID.

Parameters

string $id Session ID associated with the data to be retrieved

Return Value

string data associated with that ID or empty string on failure

bool write(string $id, string $data)

Write an element to Memcache with the given ID and data.

Parameters

string $id Session ID associated with the data to be stored
string $data Data to be stored

Return Value

bool true if successful, false otherwise

bool destroy(string $id)

Destroy the data associated with a particular session ID.

Parameters

string $id Session ID associated with the data to be destroyed

Return Value

bool true if successful, false otherwise

bool gc(int $maxlifetime)

Garbage collection method - always returns true as this is handled by the Memcache expire function.

Parameters

int $maxlifetime Not used

Return Value

bool true if successful, false otherwise

static configure(MemcacheContainer $memcacheContainer = null)

Configure the session handler to use the Memcache API.

Parameters

MemcacheContainer $memcacheContainer Optional, for mocking in tests