Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 2.69 KB

cache-drivers.md

File metadata and controls

79 lines (56 loc) · 2.69 KB

Cache drivers

If you want to make use of BotMans Conversation feature, you need to use a persistent cache driver, where BotMan can store and retrieve the conversations. If not specified otherwise, BotMan will use the array cache which is non-persistent.

{callout-info} If you use BotMan Studio it is not required to specify cache drivers manually, as Laravel handles this for you.

PSR-6 Cache

If your framework / cache driver is not explicitly supported by BotMan, you can see if your cache driver supports the PSR-6 Caching Interface. With the PSR-6 BotMan cache driver, you can use all supported cache drivers with BotMan.

use BotMan\BotMan\Cache\Psr6Cache;

$adapter = new MyCustomPsr6CacheAdapter();
$botman = BotManFactory::create($config, new Psr6Cache($adapter));

Laravel Cache

When using botman in an existing Laravel project, you can use the Botman's built in LaravelCache.

use BotMan\BotMan\Cache\LaravelCache;

$botman = BotManFactory::create($config, new LaravelCache());

Doctrine Cache

Use any Doctrine Cache driver by passing it to the factory:

use BotMan\BotMan\Cache\DoctrineCache;

$botman = BotManFactory::create($config, new DoctrineCache($doctrineCacheDriver));

CodeIgniter Cache

Use any CodeIgniter Cache adapter by passing it to the factory:

use BotMan\BotMan\Cache\CodeIgniterCache;

$this->load->driver('cache');
$botman = BotManFactory::create($config, new CodeIgniterCache($this->cache->file));

Redis Cache

Use your Redis in-memory data structure to cache BotMan conversation information. If you have the igbinary module available, it will be used instead of standard PHP serializer:

use BotMan\BotMan\Cache\RedisCache;

$botman = BotManFactory::create($config, new RedisCache('127.0.0.1', 6379));

Symfony Cache

Use any Symfony Cache component by passing it to the factory:

use BotMan\BotMan\Cache\SymfonyCache;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

$adapter = new FilesystemAdapter();
$botman = BotManFactory::create($config, new SymfonyCache($adapter));