PHP code example of amber / cache

1. Go to this page and download the library: Download amber/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/ */

    

amber / cache example snippets


use Amber\Cache\Cache;

$cache = Cache::getInstance();

use Amber\Cache\Cache;

$cache = Cache::driver('file');

$drivers = [
    'file'  => 'Amber\Cache\Driver\SimpleCache',
    'json'  => 'Amber\Cache\Driver\JsonCache',
    'array' => 'Amber\Cache\Driver\ArrayCache',
    'apcu'  => 'Amber\Cache\Driver\ApcuCache',
];

$cache = Cache::driver(Amber\Cache\Driver\SimpleCache::class);

$cache = new \Amber\Cache\Driver\SimpleCache();

$cache->get($key, $default = null);

$cache->set($key, $value, $ttl = null);

$cache->delete($key);

$cache->clear();

$cache->has($key);

$cache->getMultiple($keys, $default = null);

$cache->setMultiple($values, $ttl = null);

$cache->deleteMultiple($keys);

use Amber\Cache\Cache;

Cache::set('key', 'value');

Cache::has('key'); // Returns true

Cache::get('key'); // Returns "value"

Cache::delete('key');

// Set the driver and then call the desired method.
Cache::driver('json')->set('key', 'value');