doctrine / doctrine/phpcr-odm

class cache? and referrers cache?

Open
#392 0 comments 0 reactions 0 assignees View on GitHub
performance
Dominant language
PHP
Stars
181
Forks
102
PR merge metrics
No merged PRs in 30d

Description

while investigating a website using phpcr-odm, i found that after setting a depth of 2 there are two things left that lead to a lot of unnecessary requests:
- parent / single child annotations always lead to getting that parent or child (parent won't be pre-fetched, child sometimes also not). the problem is that we do not know the class of the target, and thus can not create the correct proxy without having the node. i see 2 options:
- we could allow to specify the class in the mapping. this is not always possible, and even if it is we might miss that a child / parent is of a subclass of the configured class. not very cool.
- we could build a (persisted) cache of path => fqn class to build proxies without loading the node. this will however degrade performance if many of the child proxy are accessed (not with status quo, but i am preparing a PR to collect all child and the parent and fetch them with getNodes)
- referrers resolution has to be done with NodeInterface::getReferrers - PHPCR seems to offer no way to batch that, even if we would know this is going to happen. i wonder if we could cache that across requests as well. probably this should be cached on jackalope level, rather than in the odm, to be sure we properly invalidate when needed.

any thoughts?

Contributor guide

Open the contributing guide

Research direction

Start by tracing parent and child annotation resolution and the NodeInterface::getReferrers calls, then review the existing getNodes prefetch path and Jackalope cache behavior. No implementation files or tests are named in the issue. Done would require an agreed caching design, correct invalidation across requests, and coverage for proxy creation and referrer resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.