phpcr-odm
phpcr-odm copied to clipboard
class cache? and referrers cache?
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?