MediaWiki master
MediaWiki\Session\SessionStore Interface Reference

This is a session store abstraction layer, which can be used to read and write sessions to configured backend(s). More...

Inherits LoggerAwareInterface.

Inherited by MediaWiki\Session\MultiBackendSessionStore, and MediaWiki\Session\SingleBackendSessionStore.

Collaboration diagram for MediaWiki\Session\SessionStore:

Public Member Functions

 delete (SessionInfo $sessionInfo)
 Delete the session data for a given ID from the session store.
 
 get (SessionInfo $sessionInfo)
 Retrieves the session data for a given session ID.
 
 set (SessionInfo $sessionInfo, $value, $exptime=0, $flags=0)
 Write the session data for a given key to the session store.
 
 shutdown ()
 Will be called during shutdown.
 

Detailed Description

This is a session store abstraction layer, which can be used to read and write sessions to configured backend(s).

Backends can be single or multiple, depending on the configuration of the site.

Sessions are read or written to the store(s), depending on the session type. The get(), set() and delete() methods are in charge of deciding the relevant store to fetch, write, or delete content from. Sessions can be strongly persistent or weakly persistent based on their type.

Storage expectations

The SessionManager should be configured with a very fast storage system that is optimized for holding key-value pairs. It expects:

  • Low latencies. Session data is read or written to during nearly all web requests from people who have contributed to or otherwise engaged with the site, including those not logged in with a registered account.
  • Locally writable data. The data must be writable from both primary and secondary data centres.
  • Locally latest reads. Writes must by default be immediately consistent within the local data centre, and visible to other reads from web servers in that data centre.
  • Replication. The data must be eventually consistent across all data centres. Writes are either synced to all remote data centres, or locally overwritten by another write that is.

The SessionManager uses set() and delete() for write operations, which should be synchronous in the local data centre, and replicate asynchronously to any others.

Anonymous sessions (used mainly for login/signup) can share the same storage as logged-in sessions, or can use a separate store. On high-traffic wikis, separating the two can help reduce storage needs, and isolate logged-in users from problems caused by spikes of anonymous sessions (which can be generated by web crawlers and are easier to DoS).

The loss of anonymous sessions is less disruptive than the loss of authenticated sessions (will typically only affect users who are right in the middle of login or signup) and so a store with less redundancy or persistence can be used.

Since
1.45

Definition at line 53 of file SessionStore.php.

Member Function Documentation

◆ delete()

MediaWiki\Session\SessionStore::delete ( SessionInfo $sessionInfo)

Delete the session data for a given ID from the session store.

Parameters
SessionInfo$sessionInfo

Implemented in MediaWiki\Session\MultiBackendSessionStore, and MediaWiki\Session\SingleBackendSessionStore.

◆ get()

MediaWiki\Session\SessionStore::get ( SessionInfo $sessionInfo)

Retrieves the session data for a given session ID.

Should return false if the session is not found.

Parameters
SessionInfo$sessionInfo
Returns
mixed

Implemented in MediaWiki\Session\MultiBackendSessionStore, and MediaWiki\Session\SingleBackendSessionStore.

Referenced by MediaWiki\Session\SessionBackend\__construct().

◆ set()

MediaWiki\Session\SessionStore::set ( SessionInfo $sessionInfo,
$value,
$exptime = 0,
$flags = 0 )

Write the session data for a given key to the session store.

Parameters
SessionInfo$sessionInfo
mixed$value
int$exptime
int$flagsShould be one of BagOStuff::WRITE_* constants

Implemented in MediaWiki\Session\MultiBackendSessionStore, and MediaWiki\Session\SingleBackendSessionStore.

◆ shutdown()

MediaWiki\Session\SessionStore::shutdown ( )

Will be called during shutdown.

Returns
void

Implemented in MediaWiki\Session\MultiBackendSessionStore, and MediaWiki\Session\SingleBackendSessionStore.


The documentation for this interface was generated from the following file: