Auth0\SDK\Helpers\Cache\FileSystemCacheHandler::get PHP Method

get() public method

public get ( $key )
    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));
    }

Usage Example

Example #1
0
 public function testFileSystemCache()
 {
     $cache = new FileSystemCacheHandler();
     $this->assertNull($cache->get('pepe'));
     $cache->set('pepe', 'lala');
     $this->assertEquals('lala', $cache->get('pepe'));
     $cache->delete('pepe');
     $this->assertNull($cache->get('pepe'));
 }