Skip to content

Commit

Permalink
Minimum PHP version in composer is 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mmamedov committed Mar 17, 2018
1 parent 539db38 commit d5d7784
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=5.5.0",
"php": ">=5.6.0",
"psr/simple-cache": "^1.0",
"psr/log": "^1.0"
},
Expand All @@ -28,7 +28,7 @@
"symfony/process": "^3.4 || ^4.0"
},
"suggest": {
"monolog/monolog": "Allows using custom logging subsystem",
"monolog/monolog": "Allows using monolog for logging",
"mobiledetect/mobiledetectlib": "Allows separate cache versions for mobile pages"
},
"autoload": {
Expand Down
7 changes: 3 additions & 4 deletions examples/demo-default-logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file is part of the PageCache package.
*
* @author Muhammed Mamedov <[email protected]>
* @copyright 2016
* @copyright 2018
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -41,13 +41,12 @@
}



?>
<html>
<body>
<h1>PageCache logging with default Logger example</h1>
<h3 style="color: red">This is a demo PageCache page that is going to be cached. Monolog log entries are saved.</h3>
<h3>Check out examples/log/monolog.log file for Monolog entries.</h3>
<h3 style="color: red">This is a demo PageCache page that is going to be cached.</h3>
<h3>Check out examples/log/default_logger.log file for logger entries.</h3>
<h3>Default cache expiration time for this page is 20 minutes. You can change this value in your <i>conf.php</i>
and passing its file path to PageCache constructor, or by calling <i>setExpiration()</i> method.
<span style="color: green;">Refresh browser to see changes.</span></h3>
Expand Down
12 changes: 12 additions & 0 deletions src/PageCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ public function init()
ob_start([$this, 'storePageHandler']);
}

/**
* Invoked by ob_start() to store page content
*
* @param string $content from ob_start
* @return string Contents of the page
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
private function storePageHandler($content)
{
try {
Expand All @@ -166,6 +173,7 @@ private function storePageHandler($content)
* Get Default Cache Adapter
*
* @return FileSystemCacheAdapter
* @throws PageCacheException
*/
private function getDefaultCacheAdapter()
{
Expand Down Expand Up @@ -349,6 +357,7 @@ public function setStrategy(StrategyInterface $strategy)
* @param \PageCache\Storage\CacheItemInterface|null $item
*
* @throws \PageCache\PageCacheException
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function clearPageCache(CacheItemInterface $item = null)
{
Expand All @@ -369,6 +378,7 @@ public function clearPageCache(CacheItemInterface $item = null)
* Return current page cache as a string or false on error, if this page was cached before.
*
* @return string|false
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function getPageCache()
{
Expand All @@ -384,6 +394,7 @@ public function getPageCache()
* @param \PageCache\Storage\CacheItemInterface|null $item
*
* @return bool Returns true if page has a valid cache file saved, false if not
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function isCached(CacheItemInterface $item = null)
{
Expand Down Expand Up @@ -418,6 +429,7 @@ private function getItemStorage()
* Detect and return current page cached item (or null if current page was not cached yet)
*
* @return \PageCache\Storage\CacheItemInterface|null
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
private function getCurrentItem()
{
Expand Down
12 changes: 7 additions & 5 deletions src/Storage/FileSystem/FileSystemCacheAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class FileSystemCacheAdapter implements CacheInterface
* FileSystemPsrCacheAdapter constructor.
*
* @param string $path
* @param int $fileLock
* @param int $minFileSize
* @param int $fileLock
* @param int $minFileSize
* @throws \PageCache\PageCacheException
*/
public function __construct($path, $fileLock, $minFileSize)
{
Expand Down Expand Up @@ -131,16 +132,17 @@ public function get($key, $default = null)
/**
* Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
*
* @param string $key The key of the item to store.
* @param mixed $value The value of the item to store, must be serializable.
* @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
* @param string $key The key of the item to store.
* @param mixed $value The value of the item to store, must be serializable.
* @param null|int|DateInterval $ttl Optional. The TTL value of this item. If no value is sent and
* the driver supports TTL then the library may set a default value
* for it or let the driver take care of that.
*
* @return bool True on success
*
* @throws \Psr\SimpleCache\InvalidArgumentException If the $key string is not a legal value.
* @throws \PageCache\Storage\CacheAdapterException
* @throws \Exception
*/
public function set($key, $value, $ttl = null)
{
Expand Down

0 comments on commit d5d7784

Please sign in to comment.