jFormsSession
in package
This class acts as a cache proxy during a request processing, for jForms containers. It allows to get and store jForms containers data into an external storage using jCache.
Containers data can be huge, and we don't need all of them at each HTTP requests. Storing containers data outside the PHP session allows to save memory and io bandwidth during the load of session data at each requests.
However, the moment where PHP session data are saved (at the end of each HTTP requests processing), is a good time to save containers data used during the HTTP request, because we know that at this moment we don't need anymore of the containers data.
This is why jFormsSession instances are stored into PHP Sessions anyway, but without containers data.
Its __sleep()
methods forbid the PHP session manager to save containers data. Instead, the __sleep()
saves itself these data with jCache.
A profile for jCache, named 'jforms', may be declared in profiles.ini.php, so you can choose where jforms data are stored. A virtual profile is used if no one is defined, and use files for the cache.
Tags
Table of Contents
- DEFAULT_ID = 0
- $containers : array<string|int, jFormsDataContainer>
- __construct() : mixed
- __sleep() : mixed
- __wakeup() : mixed
- deleteContainer() : mixed
- flushAll() : mixed
- garbage() : mixed
- getCacheKey() : array<string|int, mixed>
- calculate the cache key corresponding to a form instance.
- getContainer() : mixed
- save() : mixed
- Saves containers data that have been created or loaded.
- loadProfile() : mixed
- Check or create if needed, that there is a profile for jCache.
Constants
DEFAULT_ID
public
mixed
DEFAULT_ID
= 0
Tags
Properties
$containers
protected
array<string|int, jFormsDataContainer>
$containers
= array()
keys are cache keys
Tags
Methods
__construct()
public
__construct() : mixed
Tags
Return values
mixed —__sleep()
public
__sleep() : mixed
Tags
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Tags
Return values
mixed —deleteContainer()
public
deleteContainer(mixed $formSel, mixed $formId) : mixed
Parameters
- $formSel : mixed
- $formId : mixed
Tags
Return values
mixed —flushAll()
public
flushAll() : mixed
Tags
Return values
mixed —garbage()
public
garbage() : mixed
Tags
Return values
mixed —getCacheKey()
calculate the cache key corresponding to a form instance.
public
getCacheKey(string $formSel, mixed $formId) : array<string|int, mixed>
Parameters
- $formSel : string
-
the selector of the form
- $formId : mixed
-
the id of the instance
Tags
Return values
array<string|int, mixed> —first element is a selector object, second is the normalized form id third is the key as string
getContainer()
public
getContainer(mixed $formSel, mixed $formId, mixed $createIfNeeded) : mixed
Parameters
- $formSel : mixed
- $formId : mixed
- $createIfNeeded : mixed
Tags
Return values
mixed —save()
Saves containers data that have been created or loaded.
public
save() : mixed
Tags
Return values
mixed —loadProfile()
Check or create if needed, that there is a profile for jCache.
protected
loadProfile() : mixed