Skip to content

Commit

Permalink
Added caching example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Hall committed Aug 8, 2017
1 parent bf0cc29 commit 6cdbbd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
composer.lock
composer.lock
**/cache/**
15 changes: 14 additions & 1 deletion src/Example.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
<?php
require __DIR__.'/../vendor/autoload.php';

use \RapidWeb\Search\Search;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Cache\Adapter\Filesystem\FilesystemCachePool;

if (!class_exists('Cache\Adapter\Filesystem\FilesystemCachePool')) {
die('This example requires the `FilesystemCachePool` class. Install it with `composer require cache/filesystem-adapter`.'.PHP_EOL);
}

$filesystemAdapter = new Local(__DIR__.'/');
$filesystem = new Filesystem($filesystemAdapter);
$cacheItemPool = new FilesystemCachePool($filesystem);

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

$search = new Search;

$search->setDatabaseConnection($pdo)
// ->setCache($cacheItemPool, 60*60*24)
->setCache($cacheItemPool, 60*60*24)
->setTable('products')
->setPrimaryKey('product_groupid')
->setFieldsToSearch(['product_name', 'product_description', 'product_seokeywords'])
Expand Down

0 comments on commit 6cdbbd8

Please sign in to comment.