| Recommend this page to a friend! | 
|  Download | 
| Info | Documentation |  Files |  Install with Composer |  Download | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not yet rated by the users | Total: 183 | All time:  8,686 This week: 206  | ||||
| Version | License | PHP version | Categories | |||
| phpcache 1.1.1 | GNU General Publi... | 7.2 | Networking, PHP 5, Databases, Cache, P... | 
| Description | Author | |||
| This package can store and retrieve cached data in a network server. Innovation Award 
 | 
Cache implementation for php
composer
#### Installing via composer:
composer require kdudas/php-cache
Objects
#### Creating a new server instance
<?php
ini_set('log_errors', 1); ini_set('error_log', '/var/log/php-cache.log'); require_once 'vendor/autoload.php';
use PhpCache\CacheServer\CacheServer; use PhpCache\ServiceManager\ConfigAggregator; use PhpCache\ServiceManager\ServiceManager; // You can import multiple config files to overwrite parameters in the basic config or add extra parameters, including dependency injection $config = include_once 'config.php'; $configAggregator = new ConfigAggregator(); $configAggregator->addConfig($config); $serviceManager = new ServiceManager($configAggregator->getMergedConfig()); $server = $serviceManager->get(CacheServer::class); $server->run();
#### Running the server:
php testServer.php
#### OR
mv daemon.sh /etc/init.d/php-cache chmod +x /etc/init.d/php-cache
sudo service php-cache start
##### Note: you can modify the contents of `daemon.sh` if you want to use other directories
#### Configuration array:
- `config`: Basic configuration array  
-- `memoryLimit`: as the name suggests, after we exceed the limit, our data in the cache pool gets backed up to file system  
-- `location`: server IP address or socket file location (string)  
-- `port`: the port to run the sockets on (number)  
-- `bufferSize`: how big chunks of data is being read from a stream (bytes)  
-- `ttl`: time to live; how long an entry should take space up in the cache pool before being deleted (seconds)  
-- `backupTime`: schedule backups (seconds)  
-- `backupDir`: where to store backed up data? A backup is made when we are shutting down the server service, when the scheduled backup occures or our cache pool exceeded it's memory limit  
-- `socketType`: which socket type should we use? Open a port on the network for the socket or create a file for the socket. Values must be either `file` (`CacheIOHandler::SOCKET_TYPE_FILE`) or `ip` (`CacheIOHandler::SOCKET_TYPE_IP`)  
- `services`: service manager configuration  
-- `aliases`: a name assigned for a real service (Example: `'cache-server' => CacheServer::class`)  
-- `factories`: service name with factory name for service pairs  
-- `invokables`: services with no dependencies  
#### Creating a new client instance
<?php include_once('vendor/autoload.php');
use PhpCache\CacheClient\CacheClient; use PhpCache\ServiceManager\ServiceManager;
$config = require_once 'config.php'; $serviceManager = new ServiceManager($config); /@var $client CacheClient/ $client = $serviceManager->get(CacheClient::class); $client->set('test', 'ASD'); echo $client->get('test');
##### You can run the client either from browser or console
php testClient.php
#### CLI Commands:
`./phpCache get <key>` gets entries for the specified key. If no key is specified, it returns all entries.  
`./phpCache set <key> <value>` pushes an entry to the cache pool with the given key - value pair.  
`./phpCache delete <key>` deletes the entry with the given key|  Files (39) | 
| File | Role | Description | ||
|---|---|---|---|---|
|  .phan (1 file) | ||||
|  src (7 directories) | ||||
|  composer.json | Data | Auxiliary data | ||
|  composer.lock | Data | Auxiliary data | ||
|  config.php | Conf. | Configuration script | ||
|  daemon.sh | Data | Auxiliary data | ||
|  LICENSE | Lic. | License text | ||
|  parallel_commands.sh | Data | Script to create parallel connections to server socket (for stress testing purposes) | ||
|  pharBuilder.php | Example | Example script | ||
|  phpCache | Example | Example script | ||
|  README.md | Doc. | Documentation | ||
|  testClient.php | Example | Class source | ||
|  testServer.php | Example | Class source | ||
|  Files (39) | / | src | 
| File | Role | Description | ||
|---|---|---|---|---|
|  CacheClient (3 files) | ||||
|  CacheEventListener (2 files) | ||||
|  CacheServer (4 files) | ||||
|  Commands (4 files) | ||||
|  IO (2 files, 1 directory) | ||||
|  ServiceManager (3 files, 1 directory) | ||||
|  Storage (5 files, 1 directory) | ||||
|  Files (39) | / | src | / | CacheClient | 
| File | Role | Description | 
|---|---|---|
|  CacheClient.php | Class | Class source | 
|  CacheClientFactory.php | Class | Class source | 
|  ClientInterface.php | Class | Class source | 
|  Files (39) | / | src | / | CacheEventListener | 
| File | Role | Description | 
|---|---|---|
|  CacheEventListenerInterface.php | Class | Class source | 
|  CacheEventListenerInterface.php | Class | Class source | 
|  Files (39) | / | src | / | CacheServer | 
| File | Role | Description | 
|---|---|---|
|  ActionHandler.php | Class | Class source | 
|  CacheServer.php | Class | Class source | 
|  CacheServerFactory.php | Class | Class source | 
|  CacheServerInterface.php | Class | Class source | 
|  Files (39) | / | src | / | Commands | 
| File | Role | Description | 
|---|---|---|
|  DeleteCommand.php | Class | Added console comma | 
|  GetCommand.php | Class | Added console comma | 
|  QuitCommand.php | Class | Class source | 
|  SetCommand.php | Class | Added console comma | 
|  Files (39) | / | src | / | IO | 
| File | Role | Description | ||
|---|---|---|---|---|
|  Exception (2 files) | ||||
|  CacheIOHandler.php | Class | Class source | ||
|  CacheIOHandlerFactory.php | Class | Class source | ||
|  Files (39) | / | src | / | IO | / | Exception | 
| File | Role | Description | 
|---|---|---|
|  InvalidConfigException.php | Class | Class source | 
|  IOException.php | Class | Class source | 
|  Files (39) | / | src | / | ServiceManager | 
| File | Role | Description | ||
|---|---|---|---|---|
|  Exception (1 file) | ||||
|  ConfigAggregator.php | Class | Class source | ||
|  ConfigAggregator.php | Class | Class source | ||
|  ServiceManager.php | Class | Dependency injection logic | ||
|  Files (39) | / | src | / | ServiceManager | / | Exception | 
| File | Role | Description | 
|---|---|---|
|  NotFoundException.php | Class | Class source | 
|  Files (39) | / | src | / | Storage | 
| File | Role | Description | ||
|---|---|---|---|---|
|  Exception (1 file) | ||||
|  Bucket.php | Class | Class source | ||
|  BucketFactory.php | Class | Class source | ||
|  Maintainer.php | Class | Class source | ||
|  MaintainerFactory.php | Class | Class source | ||
|  StorageInterface.php | Class | Class source | ||
|  Files (39) | / | src | / | Storage | / | Exception | 
| File | Role | Description | 
|---|---|---|
|  StorageException.php | Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
|  Install with Composer | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
 | 
 | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.
 If you know an application of this package, send a message to the author to add a link here.
| Related pages | 
| This is the github repository url for this lib. The README.md is more readable there and I push there frequently |