Skip to content

Commit 1bffc74

Browse files
authored
Merge pull request #495 from Geolim4/final
Improved examples path + Added fetchAllKeys exemple
2 parents 0cbe886 + e56a0f9 commit 1bffc74

21 files changed

+76
-20
lines changed

docs/examples/SaveMultiple.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414
// Include composer autoloader
15-
require __DIR__ . '/../vendor/autoload.php';
15+
require __DIR__ . '/../../vendor/autoload.php';
1616
// OR require_once("../src/phpFastCache/phpFastCache.php");
1717

1818
use phpFastCache\CacheManager;

docs/examples/apc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use phpFastCache\CacheManager;
1515

1616
// Include composer autoloader
17-
require __DIR__ . '/../vendor/autoload.php';
17+
require __DIR__ . '/../../vendor/autoload.php';
1818

1919
$InstanceCache = CacheManager::getInstance('apc');
2020

docs/examples/cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use phpFastCache\CacheManager;
1515

1616
// Include composer autoloader
17-
require __DIR__ . '/../vendor/autoload.php';
17+
require __DIR__ . '/../../vendor/autoload.php';
1818

1919
$InstanceCache = CacheManager::getInstance('cookie');
2020

docs/examples/couchbase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use phpFastCache\CacheManager;
1616

1717
// Include composer autoloader
18-
require __DIR__ . '/../vendor/autoload.php';
18+
require __DIR__ . '/../../vendor/autoload.php';
1919

2020
$InstanceCache = CacheManager::getInstance('couchbase', [
2121
'host' => 'your-couchbase-host',

docs/examples/decrement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
// Include composer autoloader
16-
require __DIR__ . '/../vendor/autoload.php';
16+
require __DIR__ . '/../../vendor/autoload.php';
1717
// OR require_once("../src/phpFastCache/phpFastCache.php");
1818
date_default_timezone_set("Europe/Paris");
1919

docs/examples/fetchAllKeys.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of phpFastCache.
5+
*
6+
* @license MIT License (MIT)
7+
*
8+
* For full copyright and license information, please see the docs/CREDITS.txt file.
9+
*
10+
* @author Khoa Bui (khoaofgod) <[email protected]> http://www.phpfastcache.com
11+
* @author Georges.L (Geolim4) <[email protected]>
12+
*
13+
*/
14+
use phpFastCache\CacheManager;
15+
16+
// Include composer autoloader
17+
require __DIR__ . '/../../vendor/autoload.php';
18+
19+
$InstanceCache = CacheManager::getInstance('files');
20+
$InstanceCache->clear();
21+
22+
/**
23+
* @var $keys \phpFastCache\Core\Item\ExtendedCacheItemInterface[]
24+
*/
25+
$keyPrefix = "product_page_";
26+
$keys = [];
27+
28+
for ($i=1;$i<=10;$i++)
29+
{
30+
$keys[$keyPrefix . $i] = $InstanceCache->getItem($keyPrefix . $i);
31+
if(!$keys[$keyPrefix . $i]->isHit()){
32+
$keys[$keyPrefix . $i]
33+
->set(uniqid('pfc', true))
34+
->addTag('pfc');
35+
}
36+
}
37+
38+
$InstanceCache->saveMultiple($keys);
39+
40+
/**
41+
* Remove items references from memory
42+
*/
43+
unset($keys);
44+
$InstanceCache->detachAllItems();
45+
gc_collect_cycles();
46+
47+
48+
/**
49+
* Now get the items by a specific tag
50+
*/
51+
$keys = $InstanceCache->getItemsByTag('pfc');
52+
foreach ($keys as $key) {
53+
echo "Key: {$key->getKey()} =&gt; {$key->get()}<br />";
54+
}
55+
56+
echo '<br /><br /><a href="/">Back to index</a>&nbsp;--&nbsp;<a href="./' . basename(__FILE__) . '">Reload</a>';

docs/examples/files.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414
// Include composer autoloader
15-
require __DIR__ . '/../vendor/autoload.php';
15+
require __DIR__ . '/../../vendor/autoload.php';
1616
// OR require_once("../src/phpFastCache/phpFastCache.php");
1717
date_default_timezone_set("Europe/Paris");
1818

docs/examples/increment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414
// Include composer autoloader
15-
require __DIR__ . '/../vendor/autoload.php';
15+
require __DIR__ . '/../../vendor/autoload.php';
1616
// OR require_once("../src/phpFastCache/phpFastCache.php");
1717
date_default_timezone_set("Europe/Paris");
1818

docs/examples/itemDetailedDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414
// Include composer autoloader
15-
require __DIR__ . '/../vendor/autoload.php';
15+
require __DIR__ . '/../../vendor/autoload.php';
1616
// OR require_once("../src/phpFastCache/phpFastCache.php");
1717
date_default_timezone_set("Europe/Paris");
1818

docs/examples/leveldb.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*/
1414
// Include composer autoloader
15-
require __DIR__ . '/../vendor/autoload.php';
15+
require __DIR__ . '/../../vendor/autoload.php';
1616
// OR require_once("../src/phpFastCache/phpFastCache.php");
1717
date_default_timezone_set("Europe/Paris");
1818

0 commit comments

Comments
 (0)