PdoCache.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Simple;
  11. use Symfony\Component\Cache\Adapter\PdoAdapter;
  12. use Symfony\Component\Cache\Marshaller\MarshallerInterface;
  13. use Symfony\Component\Cache\PruneableInterface;
  14. use Symfony\Component\Cache\Traits\PdoTrait;
  15. use Symfony\Contracts\Cache\CacheInterface;
  16. @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', PdoCache::class, PdoAdapter::class, CacheInterface::class), \E_USER_DEPRECATED);
  17. /**
  18. * @deprecated since Symfony 4.3, use PdoAdapter and type-hint for CacheInterface instead.
  19. */
  20. class PdoCache extends AbstractCache implements PruneableInterface
  21. {
  22. use PdoTrait;
  23. protected $maxIdLength = 255;
  24. /**
  25. * You can either pass an existing database connection as PDO instance or
  26. * a Doctrine DBAL Connection or a DSN string that will be used to
  27. * lazy-connect to the database when the cache is actually used.
  28. *
  29. * When a Doctrine DBAL Connection is passed, the cache table is created
  30. * automatically when possible. Otherwise, use the createTable() method.
  31. *
  32. * List of available options:
  33. * * db_table: The name of the table [default: cache_items]
  34. * * db_id_col: The column where to store the cache id [default: item_id]
  35. * * db_data_col: The column where to store the cache data [default: item_data]
  36. * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
  37. * * db_time_col: The column where to store the timestamp [default: item_time]
  38. * * db_username: The username when lazy-connect [default: '']
  39. * * db_password: The password when lazy-connect [default: '']
  40. * * db_connection_options: An array of driver-specific connection options [default: []]
  41. *
  42. * @param \PDO|Connection|string $connOrDsn a \PDO or Connection instance or DSN string or null
  43. *
  44. * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string
  45. * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
  46. * @throws InvalidArgumentException When namespace contains invalid characters
  47. */
  48. public function __construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null)
  49. {
  50. $this->init($connOrDsn, $namespace, $defaultLifetime, $options, $marshaller);
  51. }
  52. }