Download the PHP package sanchescom/laravel-cache-memory without Composer
On this page you can find all versions of the php package sanchescom/laravel-cache-memory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sanchescom/laravel-cache-memory
More information about sanchescom/laravel-cache-memory
Files in sanchescom/laravel-cache-memory
Package laravel-cache-memory
Short Description Memory cache driver.
License MIT
Homepage https://github.com/sanchescom/laravel-cache-memory
Informations about the package laravel-cache-memory
Laravel Cache Memory
Laravel cache memory driver which use shared memory functions.
Shmop is an easy to use set of functions that allows PHP to read, write, create and delete Unix shared memory segments.
Shared memory an IPC1 mechanism native to UNIX. In essence, it’s about two processes sharing a common segment of memory that they can both read to and write from to communicate with one another.
Locks and semaphores are used to ensure atomic access so that multiple PHP processes can concurrently use the same shared memory safely.
Installing
Require this package, with Composer, in the root directory of your project.
Laravel 5.x:
After updating composer, add the ServiceProvider to the providers array in config/app.php
Lumen:
After updating composer add the following lines to register provider in bootstrap/app.php
Configuration
Put new driver in config/cache.php
and set key and size for memory:
Put data to memory in one process
Get it from another process
About memory limits
Garbage collection (by removing expired items) will be performed when the cache is near the size limit. If the garbage collection fails to reduce the size of the cache below the size limit, then the cache will be invalidated and the underlying memory segment is marked for deletion.
Running out of memory will generate a warning or a notice in your logs, no matter if it is resolved by a garbage collection or by segment deletion.
Note: items that are stored as "forever" may be removed when the cache reaches its size limit.
Recreating the memory block
When recreating the memory block, the newest size limit defined in the Laravel config file will be used.
Manually marking the memory segment for deletion
There are use cases to this, such as wanting to refresh the memory block now instead of waiting for another "out of memory" event. In this case, you may do the following:
This usage will not trigger any warnings or notices since this is an action taken deliberately.
All versions of laravel-cache-memory with dependencies
ext-shmop Version *
ext-sysvsem Version *
illuminate/support Version ^8.0|^9.0|^10.0
illuminate/cache Version ^8.0|^9.0|^10.0