-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from byjg/5.0
Add TmpfsCacheEngine
- Loading branch information
Showing
8 changed files
with
147 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Class TmpfsCacheEngine | ||
|
||
This class uses the Tmpfs as the cache engine. | ||
|
||
## Defining the Path | ||
|
||
The TmpfsCacheEngine allows to store the cache files in the `/dev/shm` tmpfs. | ||
|
||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\TmpfsCacheEngine($path, $prefix) | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createTmpfsCachePool($path, $prefix, $bufferSize = 10) | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\createTmpfsCachePool($path, $prefix)); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
## Use a PSR-11 container to retrieve the cache keys | ||
|
||
You can use a PSR-11 compatible to retrieve the cache keys. Once is defined, only the keys defined | ||
in the PSR-11 will be used to cache. | ||
|
||
```php | ||
<?php | ||
$fileCache = new \ByJG\Cache\Psr16\FileSystemCacheEngine() | ||
$fileCache->withKeysFromContainer(new SomePsr11Implementation()); | ||
``` | ||
|
||
After the PSR-11 container is defined, when I run: | ||
|
||
```php | ||
$value = $fileCache->get('my-key'); | ||
``` | ||
|
||
The key `my-key` will be retrieved from the PSR-11 container and | ||
the value retrieved will be used as the cache key. | ||
If it does not exist in the PSR-11 container, an exception will be thrown. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace ByJG\Cache\Psr16; | ||
|
||
use ByJG\Cache\CacheLockInterface; | ||
use ByJG\Cache\Exception\InvalidArgumentException; | ||
use DateInterval; | ||
use Psr\Container\ContainerExceptionInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class TmpfsCacheEngine extends FileSystemCacheEngine | ||
{ | ||
|
||
public function __construct(?LoggerInterface $logger = null) | ||
{ | ||
parent::__construct('cache', '/dev/shm', $logger); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters