Redis based session handler.
More...
|
int | $acquiretimeout = 120 |
| $acquiretimeout how long to wait for session lock in seconds
|
|
string | $auth = '' |
| $auth redis password
|
|
Redis | $connection = null |
| Connection.
|
|
int | $database = 0 |
| $database the Redis database to store sesions in
|
|
string | $host = '' |
| $host save_path string
|
|
int | $lockexpire |
| $lockexpire how long to wait in seconds before expiring the lock automatically so that other requests may continue execution, ignored if PECL redis is below version 2.2.0.
|
|
array | $locks = array() |
| $locks List of currently held locks by this page.
|
|
int | $port = 6379 |
| $port The port to connect to
|
|
array | $prefix = '' |
| $servers list of servers parsed from save_path
|
|
int | $serializer = Redis::SERIALIZER_PHP |
| $serializer The serializer to use
|
|
int | $timeout |
| $timeout How long sessions live before expiring.
|
|
Redis based session handler.
The default Redis session handler does not handle locking in 2.2.7, so we have written a php session handler that uses locking. The places where locking is used was modeled from the memcached code that is used in Moodle https://github.com/php-memcached-dev/php-memcached/blob/master/php_memcached_session.c
- Copyright
- 2016 Russell Smith
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ handler_close()
core\session\redis::handler_close |
( |
| ) |
|
Close the session completely.
We also remove all locks we may have obtained that aren't expired.
- Return values
-
bool | true on success. false on unable to unlock sessions. |
◆ handler_destroy()
core\session\redis::handler_destroy |
( |
|
$id | ) |
|
Handle destroying a session.
- Parameters
-
string | $id | the session id to destroy. |
- Return values
-
bool | true if the session was deleted, false otherwise. |
◆ handler_gc()
core\session\redis::handler_gc |
( |
|
$maxlifetime | ) |
|
Garbage collect sessions.
We don't we any as Redis does it for us.
- Parameters
-
integer | $maxlifetime | All sessions older than this should be removed. |
- Return values
-
bool | true, as Redis handles expiry for us. |
◆ handler_open()
core\session\redis::handler_open |
( |
|
$savepath, |
|
|
|
$sessionname |
|
) |
| |
Update our session search path to include session name when opened.
- Parameters
-
string | $savepath | unused session save path. (ignored) |
string | $sessionname | Session name for this session. (ignored) |
- Return values
-
bool | true always as we will succeed. |
◆ handler_read()
core\session\redis::handler_read |
( |
|
$id | ) |
|
Read the session data from storage.
- Parameters
-
string | $id | The session id to read from storage. |
- Return values
-
string | The session data for PHP to process. |
- Exceptions
-
RedisException | when we are unable to talk to the Redis server. |
◆ handler_write()
core\session\redis::handler_write |
( |
|
$id, |
|
|
|
$data |
|
) |
| |
Write the serialized session data to our session store.
- Parameters
-
string | $id | session id to write. |
string | $data | session data |
- Return values
-
bool | true on write success, false on failure |
◆ kill_session()
core\session\redis::kill_session |
( |
|
$sid | ) |
|
Kill one session, the session record is removed afterwards.
- Parameters
-
Reimplemented from core\session\handler.
◆ lock_session()
core\session\redis::lock_session |
( |
|
$id | ) |
|
|
protected |
Obtain a session lock so we are the only one using it at the moent.
- Parameters
-
string | $id | The session id to lock. |
- Return values
-
bool | true when session was locked, exception otherwise. |
- Exceptions
-
exception | When we are unable to obtain a session lock. |
◆ session_exists()
core\session\redis::session_exists |
( |
|
$sid | ) |
|
◆ start()
core\session\redis::start |
( |
| ) |
|
◆ time()
core\session\redis::time |
( |
| ) |
|
|
protected |
Return the current time.
- Return values
-
int | the current time as a unixtimestamp. |
◆ unlock_session()
core\session\redis::unlock_session |
( |
|
$id | ) |
|
|
protected |
Unlock a session.
- Parameters
-
string | $id | Session id to be unlocked. |
The documentation for this class was generated from the following file: