Skip to content

Commit 6cdbbd8

Browse files
author
Jordan Hall
committed
Added caching example
1 parent bf0cc29 commit 6cdbbd8

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
2-
composer.lock
2+
composer.lock
3+
**/cache/**

src/Example.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
<?php
2+
require __DIR__.'/../vendor/autoload.php';
3+
24
use \RapidWeb\Search\Search;
5+
use League\Flysystem\Adapter\Local;
6+
use League\Flysystem\Filesystem;
7+
use Cache\Adapter\Filesystem\FilesystemCachePool;
8+
9+
if (!class_exists('Cache\Adapter\Filesystem\FilesystemCachePool')) {
10+
die('This example requires the `FilesystemCachePool` class. Install it with `composer require cache/filesystem-adapter`.'.PHP_EOL);
11+
}
12+
13+
$filesystemAdapter = new Local(__DIR__.'/');
14+
$filesystem = new Filesystem($filesystemAdapter);
15+
$cacheItemPool = new FilesystemCachePool($filesystem);
316

417
$pdo = new PDO('mysql:dbname=database_name;host=127.0.0.1', 'username', 'password');
518

619
$search = new Search;
720

821
$search->setDatabaseConnection($pdo)
9-
// ->setCache($cacheItemPool, 60*60*24)
22+
->setCache($cacheItemPool, 60*60*24)
1023
->setTable('products')
1124
->setPrimaryKey('product_groupid')
1225
->setFieldsToSearch(['product_name', 'product_description', 'product_seokeywords'])

0 commit comments

Comments
 (0)