Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cache] Create PSR-16 variants of all PSR-6 adapters
- Loading branch information
1 parent
99ae9d6
commit 6219dd6
Showing
52 changed files
with
2,707 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Symfony\Component\Cache\Traits\ApcuTrait; | ||
|
||
class ApcuAdapter extends AbstractAdapter | ||
{ | ||
use ApcuTrait; | ||
|
||
public function __construct($namespace = '', $defaultLifetime = 0, $version = null) | ||
{ | ||
$this->init($namespace, $defaultLifetime, $version); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Doctrine\Common\Cache\CacheProvider; | ||
use Symfony\Component\Cache\Traits\DoctrineTrait; | ||
|
||
class DoctrineAdapter extends AbstractAdapter | ||
{ | ||
use DoctrineTrait; | ||
|
||
public function __construct(CacheProvider $provider, $namespace = '', $defaultLifetime = 0) | ||
{ | ||
parent::__construct('', $defaultLifetime); | ||
$this->provider = $provider; | ||
$provider->setNamespace($namespace); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Symfony\Component\Cache\Traits\FilesystemTrait; | ||
|
||
class FilesystemAdapter extends AbstractAdapter | ||
{ | ||
use FilesystemTrait; | ||
|
||
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) | ||
{ | ||
parent::__construct('', $defaultLifetime); | ||
$this->init($namespace, $directory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Symfony\Component\Cache\Traits\MemcachedTrait; | ||
|
||
class MemcachedAdapter extends AbstractAdapter | ||
{ | ||
use MemcachedTrait; | ||
|
||
protected $maxIdLength = 250; | ||
|
||
public function __construct(\Memcached $client, $namespace = '', $defaultLifetime = 0) | ||
{ | ||
$this->init($client, $namespace, $defaultLifetime); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Symfony\Component\Cache\Traits\PdoTrait; | ||
|
||
class PdoAdapter extends AbstractAdapter | ||
{ | ||
use PdoTrait; | ||
|
||
protected $maxIdLength = 255; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* You can either pass an existing database connection as PDO instance or | ||
* a Doctrine DBAL Connection or a DSN string that will be used to | ||
* lazy-connect to the database when the cache is actually used. | ||
* | ||
* List of available options: | ||
* * db_table: The name of the table [default: cache_items] | ||
* * db_id_col: The column where to store the cache id [default: item_id] | ||
* * db_data_col: The column where to store the cache data [default: item_data] | ||
* * db_lifetime_col: The column where to store the lifetime [default: item_lifetime] | ||
* * db_time_col: The column where to store the timestamp [default: item_time] | ||
* * db_username: The username when lazy-connect [default: ''] | ||
* * db_password: The password when lazy-connect [default: ''] | ||
* * db_connection_options: An array of driver-specific connection options [default: array()] | ||
* | ||
* @param \PDO|Connection|string $connOrDsn A \PDO or Connection instance or DSN string or null | ||
* @param string $namespace | ||
* @param int $defaultLifetime | ||
* @param array $options An associative array of options | ||
* | ||
* @throws InvalidArgumentException When first argument is not PDO nor Connection nor string | ||
* @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION | ||
* @throws InvalidArgumentException When namespace contains invalid characters | ||
*/ | ||
public function __construct($connOrDsn, $namespace = '', $defaultLifetime = 0, array $options = array()) | ||
{ | ||
$this->init($connOrDsn, $namespace, $defaultLifetime, $options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Symfony\Component\Cache\Exception\CacheException; | ||
use Symfony\Component\Cache\Traits\PhpFilesTrait; | ||
|
||
class PhpFilesAdapter extends AbstractAdapter | ||
{ | ||
use PhpFilesTrait; | ||
|
||
public function __construct($namespace = '', $defaultLifetime = 0, $directory = null) | ||
{ | ||
if (!static::isSupported()) { | ||
throw new CacheException('OPcache is not enabled'); | ||
} | ||
parent::__construct('', $defaultLifetime); | ||
$this->init($namespace, $directory); | ||
|
||
$e = new \Exception(); | ||
$this->includeHandler = function () use ($e) { throw $e; }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Cache\Adapter; | ||
|
||
use Symfony\Component\Cache\Traits\RedisTrait; | ||
|
||
class RedisAdapter extends AbstractAdapter | ||
{ | ||
use RedisTrait; | ||
|
||
/** | ||
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient | ||
*/ | ||
public function __construct($redisClient, $namespace = '', $defaultLifetime = 0) | ||
{ | ||
$this->init($redisClient, $namespace, $defaultLifetime); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.