You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
829 B

13 years ago
13 years ago
13 years ago
  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Cache
  7. * @since 2010-03-04
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. class Cacher
  12. {
  13. /**
  14. * Initialized cachers
  15. *
  16. * @var array
  17. */
  18. static protected $caches = array();
  19. static public function get($cacher, $config = null)
  20. {
  21. if (!isset(self::$caches[$cacher])) {
  22. if (!$config) {
  23. $config = Config::get($cacher);
  24. }
  25. $cache = new $cacher($config);
  26. if (!$cache instanceof Cache) {
  27. throw new InitializationException('Cache driver "' . $cacher . '" must extends Cache');
  28. }
  29. self::$caches[$cacher] = $cache;
  30. }
  31. return self::$caches[$cacher];
  32. }
  33. }