|Ratings|| ||Unique User Downloads|| ||Download Rankings|
|Not yet rated by the users||Total: 181 ||All time: 8,640 This week: 225|
This package can store and retrieve cached data in a network server.
It can work as a client and a server that takes TCP connection requests and can store and retrieve data a in a cache container.
The client may request to store, retrieve and delete data in a cache container on the server by sending a request over a TCP connection.
The server handles the TCP request by executing the requested cache operation using arrays as storage container.
Prize: One downloadable copy of Komodo IDE
|There are several products that allow caching data very quickly and can be accessed via a local network connection.
This package can work as a client and server to store data a in a cache container that uses PHP arrays in memory for fast cache data access.
Cache implementation for php
// 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();
$serviceManager = new ServiceManager($configAggregator->getMergedConfig());
$server = $serviceManager->get(CacheServer::class);
#### Running the server:
mv daemon.sh /etc/init.d/php-cache
chmod +x /etc/init.d/php-cache
now you can use systemctl style service management
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
$config = require_once 'config.php';
$serviceManager = new ServiceManager($config);
/@var $client CacheClient/
$client = $serviceManager->get(CacheClient::class);
##### You can run the client either from browser or console
#### 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
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.