PHP Luminova: Runtime Shared Memory
Lightweight in-memory storage for global application key/value data. Works as a static runtime registry and does not save data permanently.
The Luminova boot module does more than just autoloading and application warmup. It includes a Shared Memory feature, a lightweight in-memory storage for application key/value data. It allows you save and read values during a single request. It works like a small “notepad” in memory that your application can share while it is running.
This is not real saved storage. Once the request ends, everything is gone.Think of it like temporary notes on a whiteboard that gets wiped clean after each request.
What this storage can do
- Save a value under a key
- Read it back later
- Check if a key exists
- Remove a key
- Clear all keys
- Count how many items are stored
This storage is:
Useful when you want to share values between different parts of your application without using session or passing them around manually.
- In-memory only
- Lost after each request
- Not shared between workers
- Not saved to disk
Usages
use Luminova\Boot;
// Store a value
Boot::set('theme', 'dark');
// Get a value
$theme = Boot::get('theme') ?? 'light';
// Check if it exists
if (Boot::has('theme')) {
// ...
}
// Remove one value
Boot::remove('theme');
// Clear everything
Boot::clear();
// Count how many keys are stored
$count = Boot::count();Class Definition
- Class namespace:
\Luminova\Boot - This class is marked as final and can't be subclassed
See Also:
Luminova\Funcs\shared()- Global helper for quick access.
Shared Memory Methods
set
Set a shared value.
Stores the given value under the specified key.
public static set(string $key, mixed $value): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | The key to store the value under. |
$value | mixed | The value to store. |
Return Value:
mixed - Returns the stored value.
get
Get a shared value.
Retrieves a value stored under the specified key.
public static get(string $key): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | The key to retrieve. |
Return Value:
mixed - Returns the stored value or null if not found.
Note:This method returns
nullif the key does not exist.
has
Check if a key exists in the shared storage.
public static has(string $key): boolParameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | The key to check. |
Return Value:
bool - Return true if the key exists, false otherwise.
remove
Remove a key from the shared storage.
public static remove(string $key): voidParameters:
| Parameter | Type | Description |
|---|---|---|
$key | string | The key to remove. |
clear
Clear all keys from the shared storage.
public static clear(): voidcount
Count the number of keys currently stored.
public static count(): intReturn Value:
int - Return the number of stored keys.