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

set() public method

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

Usage Example

Beispiel #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'));
 }