ApcuSessionCache
extends AbstractSessionCache
in package
APCu-based session cache implementation.
Caches FileMaker Data API session tokens using APCu, which stores data in shared memory on the server. Note that depending on your setup APCu cache may be shared across PHP processes on the same server, so cache keys must be sufficiently unique to avoid collisions between different users and applications.
Requires that the APCu extension is installed and enabled. See the documentation here for more information: https://www.php.net/apcu
As this cache stores sensitive FileMaker Data API session tokens, APCu is only appropriate in environments where server memory access is properly restricted.
Note that cache operations in this implementation are not atomic. While care has been taken to minimize the risk of race conditions, concurrent requests sharing the same cache key may occasionally result in redundant re-authentication against the FileMaker Server. This is considered an acceptable trade-off given the constraints of the current implementation.
Tags
Table of Contents
Properties
- $key : string
- The cache key for the current session.
- $ttl : int
- The time-to-live in seconds for cached session tokens.
Methods
- __construct() : mixed
- ApcuSessionCache constructor.
- delete() : bool
- Deletes the cached FileMaker Data API session token.
- get() : string|null
- Retrieves the cached FileMaker Data API session token for the current session.
- set() : bool
- Persists a FileMaker Data API session token in APCu.
- setKey() : void
- Sets the cache key for the current session.
- setTtl() : void
- Sets the time-to-live for cached session tokens.
Properties
$key
The cache key for the current session.
protected
string
$key
Always set by the library via SessionCacheInterface::setKey() before any cache operation is performed. Will not change during a single PHP request. Implementing classes should use this property directly in their SessionCacheInterface::get(), SessionCacheInterface::set(), and SessionCacheInterface::delete() implementations.
$ttl
The time-to-live in seconds for cached session tokens.
protected
int
$ttl
Set by the library via SessionCacheInterface::setTtl() before any cache operation is performed, defaulting to the value provided at construction time. Will not change during a single PHP request. Implementing classes should use this property directly in their SessionCacheInterface::set() implementation.
Methods
__construct()
ApcuSessionCache constructor.
public
__construct() : mixed
Tags
delete()
Deletes the cached FileMaker Data API session token.
public
delete() : bool
Returns false both when the key does not exist and when deletion fails.
Return values
bool —True on success, false if the key did not exist or deletion failed.
get()
Retrieves the cached FileMaker Data API session token for the current session.
public
get() : string|null
Return values
string|null —The cached session token, or null if no token exists for the current key.
set()
Persists a FileMaker Data API session token in APCu.
public
set(string $value) : bool
Parameters
- $value : string
-
The FileMaker Data API session token to store. This is a sensitive credential and must be treated as such.
Return values
bool —True on success, false on failure.
setKey()
Sets the cache key for the current session.
public
final setKey(string $key) : void
This method is called internally by the library and should not be called manually. The key will not change during a single PHP request.
Parameters
- $key : string
-
The cache key to use for subsequent cache operations.
setTtl()
Sets the time-to-live for cached session tokens.
public
final setTtl(int $ttl) : void
This method is called internally by the library and should not be called manually. The TTL will not change during a single PHP request.
Parameters
- $ttl : int
-
Time-to-live in seconds for the cached session token.