Guest User

Untitled

a guest
Sep 30th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2.  
  3. class Stash {
  4.  
  5. private $_pool;
  6.  
  7. public function __construct($options)
  8. {
  9. include_once APPPATH . '/third_party/Stash/autoload.php';
  10.  
  11. if (isset($options['stash']) && isset($options['stash']['path'])) {
  12. if (substr($options['stash']['path'], 0, 1) != '/') {
  13. $options['stash']['path'] = getcwd() . '/' . $options['stash']['path'];
  14. }
  15. }
  16.  
  17. $handler = new StashHandlerFileSystem(@$options['stash']);
  18.  
  19. $this->_pool = new StashPool;
  20. $this->_pool->setHandler($handler);
  21. }
  22.  
  23. public function getCache($path)
  24. {
  25. return $this->_pool->getCache($path);
  26. }
  27. }
  28.  
  29. ?>
  30.  
  31. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  32. /*
  33. | -------------------------------------------------------------------
  34. | Stash Cache settings
  35. | -------------------------------------------------------------------
  36. |
  37. */
  38.  
  39. $config['stash'] = array('path' => APPPATH .'/cache');
  40.  
  41. $this->load->library('Stash');
  42. $cache = $this->stash->getCache(array('key1','subkey1','subkey2'));
  43. $cache->set('foo', 'bar', 30);
Add Comment
Please, Sign In to add comment