diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-08-21 18:46:34 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-08-21 18:46:34 -0400 |
commit | 8e83e404fbb1d0dc770e5b41fa315a674541459a (patch) | |
tree | 38186a4ef5818133489b41f85f200fa28bed2806 /app/ServiceProvider/CacheProvider.php | |
parent | 836e93546355e20f5a3cca0e2fd4e649264ce7ac (diff) |
Add FileCache driver
Diffstat (limited to 'app/ServiceProvider/CacheProvider.php')
-rw-r--r-- | app/ServiceProvider/CacheProvider.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/ServiceProvider/CacheProvider.php b/app/ServiceProvider/CacheProvider.php new file mode 100644 index 00000000..0d56e601 --- /dev/null +++ b/app/ServiceProvider/CacheProvider.php @@ -0,0 +1,41 @@ +<?php + +namespace Kanboard\ServiceProvider; + +use Kanboard\Core\Cache\FileCache; +use Kanboard\Core\Cache\MemoryCache; +use Pimple\Container; +use Pimple\ServiceProviderInterface; + +/** + * Cache Provider + * + * @package Kanboard\ServiceProvider + * @author Frederic Guillot + */ +class CacheProvider implements ServiceProviderInterface +{ + /** + * Register providers + * + * @access public + * @param \Pimple\Container $container + * @return \Pimple\Container + */ + public function register(Container $container) + { + $container['memoryCache'] = function() { + return new MemoryCache(); + }; + + if (CACHE_DRIVER === 'file') { + $container['cacheDriver'] = function() { + return new FileCache(); + }; + } else { + $container['cacheDriver'] = $container['memoryCache']; + } + + return $container; + } +} |