-
-
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.
- Loading branch information
Showing
11 changed files
with
228 additions
and
14 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,27 @@ | ||
# Class ArrayCacheEngine | ||
|
||
This class is a simple cache engine that uses an array to store the values. | ||
It does not persists between requests. | ||
|
||
It is ideal to use on unit tests or when you need a simple cache engine. | ||
|
||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\ArrayCacheEngine() | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createArrayPool() | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\ArrayCacheEngine()); | ||
``` | ||
|
||
|
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,30 @@ | ||
# Class FilesystemCacheEngine | ||
|
||
This class uses the Filesystem as the cache engine. | ||
|
||
## Defining the Path | ||
|
||
The FileSystemCacheEngine expects a prefix and a path to store the cache files. | ||
The prefix is used to avoid collision between different applications using the same cache path. | ||
If the path is not defined, the default is the system temporary path. | ||
|
||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\FileSystemCacheEngine($path, $prefix) | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createFilePool($path, $prefix, $bufferSize = 10) | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\FileSystemCacheEngine($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,34 @@ | ||
# Class MemcachedEngine | ||
|
||
This class uses the Memcached as the cache engine. | ||
|
||
## Defining the Servers | ||
|
||
The constructor expects an array of servers. | ||
Each server is an item in the array with the following format: | ||
|
||
```php | ||
$servers = [ | ||
'localhost:11211', | ||
] | ||
``` | ||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\MemcachedEngine($servers) | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createMemcachedPool($servers) | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\MemcachedEngine($servers)); | ||
``` | ||
|
||
|
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,24 @@ | ||
# Class NoCacheEngine | ||
|
||
This class don't cache. Use it for disable the cache without change your code. | ||
|
||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\NoCacheEngine(); | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createNullPool(); | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\NoCacheEngine()); | ||
``` | ||
|
||
|
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,31 @@ | ||
# Class RedisCacheEngine | ||
|
||
This class uses the Redis as the cache engine. | ||
|
||
## Defining the Servers | ||
|
||
The constructor expects a string with the server and port. | ||
|
||
```php | ||
$server = 'localhost:5678' | ||
``` | ||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\RedisCacheEngine($server, $password) | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createRedisCacheEngine($server, $password) | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\RedisCacheEngine($server, $password)); | ||
``` | ||
|
||
|
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,27 @@ | ||
# Class SessionCacheEngine | ||
|
||
This class uses the PHP Session as the cache engine. | ||
This will persist the cache between requests while the user session is active. | ||
|
||
The cache is not shared between different users. | ||
|
||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\SessionCacheEngine($prefix) | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createSessionPool($prefix, $bufferSize = 10) | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\SessionCacheEngine($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,38 @@ | ||
# Class ShmopCacheEngine | ||
|
||
This class uses the PHP Shmop as the cache engine. | ||
|
||
The Shared memory allows multiple processes to access the same data in memory. | ||
You can use it to share data among running PHP scripts in the same server. | ||
|
||
## Configuration | ||
|
||
These are the default values for the configuration: | ||
|
||
```php | ||
$config = [ | ||
'max-size' => 524288, // 512Kb | ||
'default-permission' = > '0700', | ||
]; | ||
``` | ||
|
||
|
||
## PSR-16 Constructor | ||
|
||
```php | ||
$cache = new \ByJG\Cache\Psr16\ShmopCacheEngine($config, $prefix) | ||
``` | ||
|
||
## PSR-6 Constructor | ||
|
||
```php | ||
$cachePool = \ByJG\Cache\Factory::createSessionPool($prefix, $bufferSize = 10) | ||
``` | ||
|
||
or | ||
|
||
```php | ||
$cachePool = new \ByJG\Cache\Psr6\CachePool(new \ByJG\Cache\Psr16\ShmopCacheEngine($config, $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
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