PHP code example of escapework / cache

1. Go to this page and download the library: Download escapework/cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

escapework / cache example snippets


use EscapeWork\Cache\Facade as Cache;

# setting 
Cache::set('key', 'value', 'namespace'); # namespace é opcional 

# getting
# if the value don't exists in cache, the closure is called
Cache::get('key', function() {
    return 'your function to get data';
}, 'namespace');

# deleting 
Cache::delete('key');

# flush namespace 
Cache::flushNamespace('namespace');

# flush all cache 
Cache::flush();

use EscapeWork\Cache\Facade as Cache;

Cache::driver(array(
    'driver' => 'memcached', 
    'memcached' => array(
        array('host' => 'your-host', 'port' => 11211) # server settings 
    ), 
));

Cache::driver(array(
    'driver' => 'file', 
    'path'   => '/path/to/your/cache/dir/', 
));