123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace Doctrine\Common\Cache;
- use MongoCollection;
- use MongoDB\Collection;
- use const E_USER_DEPRECATED;
- use function trigger_error;
- class MongoDBCache extends CacheProvider
- {
-
- public const DATA_FIELD = 'd';
-
- public const EXPIRATION_FIELD = 'e';
-
- private $provider;
-
- public function __construct($collection)
- {
- if ($collection instanceof MongoCollection) {
- @trigger_error('Using a MongoCollection instance for creating a cache adapter is deprecated and will be removed in 2.0', E_USER_DEPRECATED);
- $this->provider = new LegacyMongoDBCache($collection);
- } elseif ($collection instanceof Collection) {
- $this->provider = new ExtMongoDBCache($collection);
- } else {
- throw new \InvalidArgumentException('Invalid collection given - expected a MongoCollection or MongoDB\Collection instance');
- }
- }
-
- protected function doFetch($id)
- {
- return $this->provider->doFetch($id);
- }
-
- protected function doContains($id)
- {
- return $this->provider->doContains($id);
- }
-
- protected function doSave($id, $data, $lifeTime = 0)
- {
- return $this->provider->doSave($id, $data, $lifeTime);
- }
-
- protected function doDelete($id)
- {
- return $this->provider->doDelete($id);
- }
-
- protected function doFlush()
- {
- return $this->provider->doFlush();
- }
-
- protected function doGetStats()
- {
- return $this->provider->doGetStats();
- }
- }
|