4
---------------------

User Entity:

/**
 * User
 *
 * @ORM\Table()
 * @ORM\Entity()
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")

// ....

/**
 * Cars of the user.
 *
 * @var ArrayCollection
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")
 * @ORM\OneToMany(targetEntity="Acme\CarBundle\Entity\Car", mappedBy="user")
 */
protected $cars;

----------------------

Car Entity:

 * @ORM\Entity()
 * @ORM\Table()
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")

// ...

/**
 * Owner of the car
 *
 * @var UserInterface
 *
 * @ORM\Cache(usage="NONSTRICT_READ_WRITE")
 * @ORM\ManyToOne(targetEntity="Acme\UserBundle\Entity\User", inversedBy="cars")
 * @ORM\JoinColumn(referencedColumnName="id")
 */
protected $user;

The problem is, that acme_userbundle_entity_user__cars never hits the cache, but puts it in every time..

Second Level Cache:

acme_carbundle_entity_car           cache hits: 8 // OK

acme_userbundle_entity_user           cache hits: 6 // OK

acme_userbundle_entity_user__cars    cache misses: 1 // WHY?

acme_userbundle_entity_user__cars    cache puts: 1 // WHY?
Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135

0 Answers0