api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
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.

CacheFactory.php 1022B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Tqdev\PhpCrudApi\Cache;
  3. use Tqdev\PhpCrudApi\Config;
  4. class CacheFactory
  5. {
  6. const PREFIX = 'phpcrudapi-%s-';
  7. private static function getPrefix(): String
  8. {
  9. return sprintf(self::PREFIX, substr(md5(__FILE__), 0, 8));
  10. }
  11. public static function create(Config $config): Cache
  12. {
  13. switch ($config->getCacheType()) {
  14. case 'TempFile':
  15. $cache = new TempFileCache(self::getPrefix(), $config->getCachePath());
  16. break;
  17. case 'Redis':
  18. $cache = new RedisCache(self::getPrefix(), $config->getCachePath());
  19. break;
  20. case 'Memcache':
  21. $cache = new MemcacheCache(self::getPrefix(), $config->getCachePath());
  22. break;
  23. case 'Memcached':
  24. $cache = new MemcachedCache(self::getPrefix(), $config->getCachePath());
  25. break;
  26. default:
  27. $cache = new NoCache();
  28. }
  29. return $cache;
  30. }
  31. }