-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple cache implementation for image hashes
- Loading branch information
1 parent
6707c1c
commit 7ea3d6a
Showing
2 changed files
with
45 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Elevinskii\MediaStorage\Model\Gallery\Image; | ||
|
||
class HashCache | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private array $cache = []; | ||
|
||
/** | ||
* Retrieve file hash by path | ||
* | ||
* @param string $path | ||
* @return string|null | ||
*/ | ||
public function get(string $path): ?string | ||
{ | ||
return $this->cache[$path] ?? null; | ||
} | ||
|
||
/** | ||
* Set file hash by path | ||
* | ||
* @return $this | ||
*/ | ||
public function set(string $path, ?string $hash): self | ||
{ | ||
$this->cache[$path] = $hash; | ||
|
||
return $this; | ||
} | ||
} |