exists() публичный Метод

Check if an entity exists in cache
public exists ( string $class_name, string $id ) : boolean
$class_name string
$id string
Результат boolean
Пример #1
0
 /**
  * @dataProvider getCacheServices
  * @param EntityCachingInterface $service
  */
 public function testStrategy(EntityCachingInterface $service)
 {
     $product = new Product();
     $product->setId(1234);
     $this->assertFalse($service->exists(Product::class, 1234));
     $service->store(Product::class, '1234', $product);
     $this->assertTrue($service->exists(Product::class, 1234));
     $r = $service->retrieve(Product::class, '1234');
     $service->purge(Product::class, '1234');
     $this->assertFalse($service->exists(Product::class, 1234));
     $this->assertEquals(1234, $r->getId());
 }
Пример #2
0
 /**
  * Retrieve an entity, throwing a NotFoundException if the entity is not found
  *
  * @param string $class_name
  * @param string $id
  * @param bool   $use_cache
  * @return object
  */
 public function retrieve($class_name, $id, $use_cache = true)
 {
     $this->validateId($id);
     if ($use_cache && $this->cache->exists($class_name, $id)) {
         return $this->cache->retrieve($class_name, $id);
     }
     $metadata = $this->mapper->getEntityMetadata($class_name);
     $serialised_data = $this->driver->retrieve($this->key_scheme->getEntityKey($metadata->getTableName(), $id));
     $writer = new Writer($metadata, $serialised_data, $this);
     $entity = $writer->getProxy();
     $this->cache->store($class_name, $id, $entity);
     return $entity;
 }