SessionService
extends AbstractDbService
in package
implements
DbTableAwareInterface, SessionServiceInterface, DeleteExpiredInterface
Uses
DbTableAwareTrait
Database service for Session.
Tags
Interfaces, Classes, Traits and Enums
- DbTableAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Table\PluginManager
- SessionServiceInterface
- Database service interface for Session.
- DeleteExpiredInterface
- Interface for exposing the "deleteExpired" method required by command line cleanup tools.
Table of Contents
- $tableManager : PluginManager
- Database table plugin manager
- createEntity() : SessionEntityInterface
- Create a session entity object.
- deleteExpired() : int
- Delete expired records. Allows setting a limit so that rows can be deleted in small batches.
- destroySession() : void
- Destroy data for the given session ID.
- garbageCollect() : int
- Garbage collect expired sessions. Returns number of deleted rows.
- getDbTable() : Gateway
- Get a database table object.
- getDbTableManager() : PluginManager
- Get the table plugin manager. Throw an exception if it is missing.
- getSessionById() : SessionEntityInterface|null
- Retrieve an object from the database based on session ID; create a new row if no existing match is found.
- persistEntity() : void
- Persist an entity.
- readSession() : string
- Retrieve data for the given session ID.
- setDbTableManager() : void
- Set the table plugin manager.
- writeSession() : bool
- Store data for the given session ID.
Properties
$tableManager
Database table plugin manager
protected
PluginManager
$tableManager
Methods
createEntity()
Create a session entity object.
public
createEntity() : SessionEntityInterface
Return values
SessionEntityInterface —deleteExpired()
Delete expired records. Allows setting a limit so that rows can be deleted in small batches.
public
deleteExpired(DateTime $dateLimit[, int|null $limit = null ]) : int
Parameters
- $dateLimit : DateTime
-
Date threshold of an "expired" record.
- $limit : int|null = null
-
Maximum number of rows to delete or null for no limit.
Return values
int —Number of rows deleted
destroySession()
Destroy data for the given session ID.
public
destroySession(string $sid) : void
Parameters
- $sid : string
-
Session ID to erase
Return values
void —garbageCollect()
Garbage collect expired sessions. Returns number of deleted rows.
public
garbageCollect(int $maxLifetime) : int
Parameters
- $maxLifetime : int
-
Maximum session lifetime.
Return values
int —getDbTable()
Get a database table object.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table to load.
Return values
Gateway —getDbTableManager()
Get the table plugin manager. Throw an exception if it is missing.
public
getDbTableManager() : PluginManager
Tags
Return values
PluginManager —getSessionById()
Retrieve an object from the database based on session ID; create a new row if no existing match is found.
public
getSessionById(string $sid[, bool $create = true ]) : SessionEntityInterface|null
Parameters
- $sid : string
-
Session ID to retrieve
- $create : bool = true
-
Should we create rows that don't already exist?
Return values
SessionEntityInterface|null —persistEntity()
Persist an entity.
public
persistEntity(EntityInterface $entity) : void
Parameters
- $entity : EntityInterface
-
Entity to persist.
Return values
void —readSession()
Retrieve data for the given session ID.
public
readSession(string $sid, int $lifetime) : string
Parameters
- $sid : string
-
Session ID to retrieve
- $lifetime : int
-
Session lifetime (in seconds)
Tags
Return values
string —Session data
setDbTableManager()
Set the table plugin manager.
public
setDbTableManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager
Return values
void —writeSession()
Store data for the given session ID.
public
writeSession(string $sid, string $data) : bool
Parameters
- $sid : string
-
Session ID to retrieve
- $data : string
-
Data to store