Added "memory" (array based) session driver to ease the unit testing of session reliant operations.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
Taylor Otwell
2012-03-07 22:16:02 -06:00
parent 51183c348d
commit 3c9a4b1aad
2 changed files with 52 additions and 0 deletions

View File

@@ -64,6 +64,9 @@ class Session {
case 'memcached': case 'memcached':
return new Session\Drivers\Memcached(Cache::driver('memcached')); return new Session\Drivers\Memcached(Cache::driver('memcached'));
case 'memory':
return new Session\Drivers\Memory;
case 'redis': case 'redis':
return new Session\Drivers\Redis(Cache::driver('redis')); return new Session\Drivers\Redis(Cache::driver('redis'));

View File

@@ -0,0 +1,49 @@
<?php namespace Laravel\Session\Drivers;
class Memory extends Driver {
/**
* The session payload that will be returned by the driver.
*
* @var array
*/
public $session;
/**
* Load a session from storage by a given ID.
*
* If no session is found for the ID, null will be returned.
*
* @param string $id
* @return array
*/
public function load($id)
{
return $this->session;
}
/**
* Save a given session to storage.
*
* @param array $session
* @param array $config
* @param bool $exists
* @return void
*/
public function save($session, $config, $exists)
{
//
}
/**
* Delete a session from storage by a given ID.
*
* @param string $id
* @return void
*/
public function delete($id)
{
//
}
}