-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move from nette/caching to own cache based on PHPStan (#202)
- Loading branch information
1 parent
9dea8d8
commit ac81e98
Showing
14 changed files
with
281 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Caching; | ||
|
||
use Rector\Caching\ValueObject\Storage\FileCacheStorage; | ||
|
||
final class Cache | ||
{ | ||
public function __construct( | ||
private FileCacheStorage $fileCacheStorage | ||
) { | ||
} | ||
|
||
/** | ||
* @return mixed|null | ||
*/ | ||
public function load(string $key, string $variableKey) | ||
{ | ||
return $this->fileCacheStorage->load($key, $variableKey); | ||
} | ||
|
||
/** | ||
* @param mixed $data | ||
*/ | ||
public function save(string $key, string $variableKey, $data): void | ||
{ | ||
$this->fileCacheStorage->save($key, $variableKey, $data); | ||
} | ||
|
||
public function clear(): void | ||
{ | ||
$this->fileCacheStorage->clear(); | ||
} | ||
|
||
public function clean(string $cacheKey): void | ||
{ | ||
$this->fileCacheStorage->clean($cacheKey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Caching\Enum; | ||
|
||
/** | ||
* @enum | ||
*/ | ||
final class CacheKey | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public const CONFIGURATION_HASH_KEY = 'configuration_hash'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public const FILE_HASH_KEY = 'file_hash'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public const DEPENDENT_FILES_KEY = 'dependency_files_key'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Caching\ValueObject; | ||
|
||
final class CacheFilePaths | ||
{ | ||
public function __construct( | ||
private string $firstDirectory, | ||
private string $secondDirectory, | ||
private string $filePath | ||
) { | ||
} | ||
|
||
public function getFirstDirectory(): string | ||
{ | ||
return $this->firstDirectory; | ||
} | ||
|
||
public function getSecondDirectory(): string | ||
{ | ||
return $this->secondDirectory; | ||
} | ||
|
||
public function getFilePath(): string | ||
{ | ||
return $this->filePath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Caching\ValueObject; | ||
|
||
/** | ||
* Inspired by | ||
* https://github.com/phpstan/phpstan-src/commit/eeae2da7999b2e8b7b04542c6175d46f80c6d0b9#diff-6dc14f6222bf150e6840ca44a7126653052a1cedc6a149b4e5c1e1a2c80eacdc | ||
*/ | ||
final class CacheItem | ||
{ | ||
/** | ||
* @param mixed $data | ||
*/ | ||
public function __construct( | ||
private string $variableKey, | ||
private $data | ||
) { | ||
} | ||
|
||
/** | ||
* @param mixed[] $properties | ||
*/ | ||
public static function __set_state(array $properties): self | ||
{ | ||
return new self($properties['variableKey'], $properties['data']); | ||
} | ||
|
||
public function isVariableKeyValid(string $variableKey): bool | ||
{ | ||
return $this->variableKey === $variableKey; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
} |
Oops, something went wrong.