PdoCache.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\PruneableInterface;
  12. use Symfony\Component\Cache\Traits\PdoTrait;
  13. class PdoCache extends AbstractCache implements PruneableInterface
  14. {
  15. use PdoTrait;
  16. protected $maxIdLength = 255;
  17. /**
  18. * You can either pass an existing database connection as PDO instance or
  19. * a Doctrine DBAL Connection or a DSN string that will be used to
  20. * lazy-connect to the database when the cache is actually used.
  21. *
  22. * List of available options:
  23. * * db_table: The name of the table [default: cache_items]
  24. * * db_id_col: The column where to store the cache id [default: item_id]
  25. * * db_data_col: The column where to store the cache data [default: item_data]
  26. * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime]
  27. * * db_time_col: The column where to store the timestamp [default: item_time]
  28. * * db_username: The username when lazy-connect [default: '']
  29. * * db_password: The password when lazy-connect [default: '']
  30. * * db_connection_options: An array of driver-specific connection options [default: []]
  31. *
  32. * @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null
  33. * @param string $namespace
  34. * @param int $defaultLifetime
  35. * @param array $options An associative array of options
  36. *
  37. * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string
  38. * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
  39. * @throws InvalidArgumentException When namespace contains invalid characters
  40. */
  41. public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = [])
  42. {
  43. $this->init($connOrDsn, $namespace, $defaultLifetime, $options);
  44. }
  45. }