Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
psa
/
admin
/
plib
/
modules
/
rest-api
/
vendor
/
jms
/
metadata
/
src
/
Cache
/
File Content:
PsrCacheAdapter.php
<?php declare (strict_types=1); namespace PleskRestApi\Metadata\Cache; use PleskRestApi\Metadata\ClassMetadata; use Psr\Cache\CacheItemPoolInterface; class PsrCacheAdapter implements CacheInterface, ClearableCacheInterface { /** * @var string */ private $prefix; /** * @var CacheItemPoolInterface */ private $pool; /** * @var CacheItemPoolInterface */ private $lastItem; public function __construct(string $prefix, CacheItemPoolInterface $pool) { $this->prefix = $prefix; $this->pool = $pool; } public function load(string $class) : ?ClassMetadata { $this->lastItem = $this->pool->getItem($this->sanitizeCacheKey($this->prefix . $class)); return $this->lastItem->get(); } public function put(ClassMetadata $metadata) : void { $key = $this->sanitizeCacheKey($this->prefix . $metadata->name); if (null === $this->lastItem || $this->lastItem->getKey() !== $key) { $this->lastItem = $this->pool->getItem($key); } $this->pool->save($this->lastItem->set($metadata)); } public function evict(string $class) : void { $this->pool->deleteItem($this->sanitizeCacheKey($this->prefix . $class)); } public function clear() : bool { return $this->pool->clear(); } /** * If anonymous class is to be cached, it contains invalid path characters that need to be removed/replaced * Example of anonymous class name: class@anonymous\x00/app/src/Controller/DefaultController.php0x7f82a7e026ec */ private function sanitizeCacheKey(string $key) : string { return \str_replace(['\\', "\x00", '@', '/', '$', '{', '}', ':'], '-', $key); } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
CacheInterface.php
531 bytes
0644
ClearableCacheInterface.php
272 bytes
0644
DoctrineCacheAdapter.php
1241 bytes
0644
FileCache.php
4068 bytes
0644
PsrCacheAdapter.php
1760 bytes
0644
N4ST4R_ID | Naxtarrr