You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// You can import multiple config files to overwrite parameters in the basic config or add extra factories
29
+
// You can import multiple config files to overwrite parameters in the basic config or add extra parameters, including dependency injection
30
30
$config = include_once 'config.php';
31
31
$configAggregator = new ConfigAggregator();
32
32
$configAggregator->addConfig($config);
@@ -42,16 +42,24 @@ php testServer.php
42
42
```
43
43
mv daemon.sh /etc/init.d/php-cache
44
44
chmod +x /etc/init.d/php-cache
45
-
# in this case you have to make the phar file globally executable because the daemon file will run it before stopping the service
46
-
# create a directory called 'phar-build' -> copy the vendor and src folders to it -> copy the phpCache file to the directory -> run pharBuilder.php.
47
-
mv php-cache.phar /usr/local/bin/php-cache
48
-
chmod +x /usr/local/bin/php-cache
49
45
# now you can use systemctl style service management
50
46
sudo service php-cache start
51
47
```
52
-
##### Note 1: you can modify the contents of `daemon.sh` if you want to use other directories
53
-
##### Note 2: A `.phar` file is a php archive file, which packs a php application into one file. If the sources or the config changes, it needs to be rebuilt!
54
-
48
+
##### Note: you can modify the contents of `daemon.sh` if you want to use other directories
49
+
#### Configuration array:
50
+
-`config`: Basic configuration array
51
+
-- `memoryLimit`: as the name suggests, after we exceed the limit, our data in the cache pool gets backed up to file system
52
+
-- `location`: server IP address or socket file location (string)
53
+
-- `port`: the port to run the sockets on (number)
54
+
-- `bufferSize`: how big chunks of data is being read from a stream (bytes)
55
+
-- `ttl`: time to live; how long an entry should take space up in the cache pool before being deleted (seconds)
56
+
-- `backupTime`: schedule backups (seconds)
57
+
-- `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
58
+
-- `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`)
59
+
-`services`: service manager configuration
60
+
-- `aliases`: a name assigned for a real service (Example: `'cache-server' => CacheServer::class`)
61
+
-- `factories`: service name with factory name for service pairs
62
+
-- `invokables`: services with no dependencies
55
63
#### Adding Server Event Listeners:
56
64
- Create a config file that looks like this:
57
65
```
@@ -116,6 +124,6 @@ echo $client->get('test');
116
124
php testClient.php
117
125
```
118
126
#### CLI Commands:
119
-
`./php-cache.phar get <key>` gets entries for the specified key. If no key is specified, it returns all entries.
120
-
`./php-cache.phar set <key> <value>` pushes an entry to the cache pool with the given key - value pair.
121
-
`./php-cache.phar delete <key>` deletes the entry with with the given key
127
+
`./phpCache get <key>` gets entries for the specified key. If no key is specified, it returns all entries.
128
+
`./phpCache set <key> <value>` pushes an entry to the cache pool with the given key - value pair.
129
+
`./phpCache delete <key>` deletes the entry with the given key
0 commit comments