Skip to content

Commit

Permalink
Added error handling for cache system (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 1, 2023
1 parent bb9ad85 commit 582dd72
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/common.neon
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extensions:
##################################

services:
cache.storage: Contributte\Cache\Storages\MemoryAdapterStorage(Nette\Caching\Storages\FileStorage(%tempDir%/cache, Nette\Caching\Storages\SQLiteJournal(%tempDir%/cache/journal.s3db)))
cache.storage: Contributte\Cache\Storages\MemoryAdapterStorage(FastyBird\Library\Bootstrap\Caching\FileStorage(%tempDir%/cache, Nette\Caching\Storages\SQLiteJournal(%tempDir%/cache/journal.s3db)))

# Symfony console support extension
###################################
Expand Down
41 changes: 41 additions & 0 deletions src/Caching/FileStorage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php declare(strict_types = 1);

/**
* Bootstrap.php
*
* @license More in LICENSE.md
* @copyright https://www.fastybird.com
* @author Adam Kadlec <[email protected]>
* @package FastyBird:Bootstrap!
* @subpackage Boot
* @since 1.0.0
*
* @date 08.03.20
*/

namespace FastyBird\Library\Bootstrap\Caching;

use Nette\Caching\Storages;
use function dirname;
use function is_dir;
use function is_file;
use function mkdir;

class FileStorage extends Storages\FileStorage
{

public function lock(string $key): void
{
$cacheFile = $this->getCacheFile($key);
if (!is_dir($dir = dirname($cacheFile))) {
@mkdir($dir); // @ - directory may already exist
}

if (!is_file($cacheFile)) {
return;
}

parent::lock($key);
}

}

0 comments on commit 582dd72

Please sign in to comment.