PrivateTempStore

Stores and retrieves temporary data for a given owner.

A PrivateTempStore can be used to make temporary, non-cache data available across requests. The data for the PrivateTempStore is stored in one key/value collection. PrivateTempStore data expires automatically after a given timeframe.

The PrivateTempStore is different from a cache, because the data in it is not yet saved permanently and so it cannot be rebuilt. Typically, the PrivateTempStore might be used to store work in progress that is later saved permanently elsewhere, e.g. autosave data, multistep forms, or in-progress changes to complex configuration that are not ready to be saved.

The PrivateTempStore differs from the SharedTempStore in that all keys are ensured to be unique for a particular user and users can never share data. If you want to be able to share data between users or use it for locking, use \Drupal\user\SharedTempStore.

Hierarchy

File

core/modules/user/src/PrivateTempStore.php, line 29

Namespace

Drupal\user

Members

Name Modifiers Type Description
PrivateTempStore::$currentUser protected property The current user.
PrivateTempStore::$expire protected property The time to live for items in seconds.
PrivateTempStore::$lockBackend protected property The lock object used for this data.
PrivateTempStore::$requestStack protected property The request stack.
PrivateTempStore::$storage protected property The key/value storage object used for this data.
PrivateTempStore::createkey protected function Ensures that the key is unique for a user.
PrivateTempStore::delete public function Deletes data from the store for a given key and releases the lock on it.
PrivateTempStore::get public function Retrieves a value from this PrivateTempStore for a given key.
PrivateTempStore::getMetadata public function Returns the metadata associated with a particular key/value pair.
PrivateTempStore::getOwner protected function Gets the current owner based on the current user or the session ID.
PrivateTempStore::set public function Stores a particular key/value pair in this PrivateTempStore.
PrivateTempStore::__construct public function Constructs a new object for accessing data from a key/value store.
doc_Drupal
2016-10-29 09:34:55
Comments
Leave a Comment

Please login to continue.