PHP code example of adrorocker / tinycache

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

    

adrorocker / tinycache example snippets




use TinyCache\Cache;
use TinyCache\Item;
use TinyCache\Adapter\FilesystemAdapter;

$cache = new Cache(new FilesystemAdapter);

$item1 = new Item('key1','Hola uno');
$item2 = new Item('key2','Hola dos');

$cache->save($item1)

// You can 'add' an Item to the cache collection before it is actually saved on the pool
$cache->saveDeferred($item2);

// Then commit to save the items on the pool
$cache->commit();

// Get an Item from the pool
$item = $cache->getItem('key1');

// Get several Items from the pool
$items = $cache->getItems(['key1','key2']);

// Delete on Item from the pool
$cache->deleteItem('key1');

// Delete several Items from the pool
$cache->deleteItems(['key1','key2']);

// Delete all Items from the pool
$cache->clear();