class FileSystemCacheHandler in Auth0 Single Sign On 8.2
Hierarchy
- class \Auth0\SDK\Helpers\Cache\FileSystemCacheHandler implements CacheHandler
Expanded class hierarchy of FileSystemCacheHandler
Deprecated
5.7.0, use a Psr\SimpleCache\CacheInterface in 7.0.0.
3 files declare their use of FileSystemCacheHandler
- CacheTest.php in vendor/
auth0/ auth0-php/ tests/ Helpers/ Cache/ CacheTest.php - JWKFetcherTest.php in vendor/
auth0/ auth0-php/ tests/ Helpers/ JWKFetcherTest.php - JWKTests.php in vendor/
auth0/ auth0-php/ tests/ API/ Helpers/ JWKTests.php
File
- vendor/
auth0/ auth0-php/ src/ Helpers/ Cache/ FileSystemCacheHandler.php, line 8
Namespace
Auth0\SDK\Helpers\CacheView source
class FileSystemCacheHandler implements CacheHandler {
/**
*
* @var string
*/
protected $tmp_dir;
/**
* FileSystemCacheHandler constructor.
*
* @param string $temp_directory_prefix
*/
public function __construct($temp_directory_prefix = 'auth0-php') {
$this->tmp_dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $temp_directory_prefix . DIRECTORY_SEPARATOR;
if (!is_dir($this->tmp_dir) && !@mkdir($this->tmp_dir, 0777, true) && !is_dir($this->tmp_dir)) {
trigger_error("Cache Handler was not able to create directory '{$this->tmp_dir}'", E_USER_WARNING);
}
}
/**
*
* @param string $key
* @return mixed|null
*/
public function get($key) {
$key = md5($key);
if (!file_exists($this->tmp_dir . $key)) {
return null;
}
$file = fopen($this->tmp_dir . $key, 'r');
flock($file, LOCK_EX);
$data = fgets($file);
flock($file, LOCK_UN);
fclose($file);
return unserialize(base64_decode($data));
}
/**
*
* @param string $key
*/
public function delete($key) {
$key = md5($key);
$this
->set($key, null);
@unlink($this->tmp_dir . $key);
}
/**
*
* @param string $key
* @param mixed $value
*/
public function set($key, $value) {
$key = md5($key);
$value = base64_encode(serialize($value));
$file = fopen($this->tmp_dir . $key, 'w+');
flock($file, LOCK_EX);
fwrite($file, $value, strlen($value));
flock($file, LOCK_UN);
fclose($file);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FileSystemCacheHandler:: |
protected | property | ||
FileSystemCacheHandler:: |
public | function |
Overrides CacheHandler:: |
|
FileSystemCacheHandler:: |
public | function |
Overrides CacheHandler:: |
|
FileSystemCacheHandler:: |
public | function |
Overrides CacheHandler:: |
|
FileSystemCacheHandler:: |
public | function | FileSystemCacheHandler constructor. |