Hi,

On Wed, Jun 10, 2009 at 3:10 PM, Carsten Ziegeler<cziege...@apache.org> wrote:
> While caching in the resource resolver might be a good idea anyway,
> perhaps caching one layer above might give even more benefit. Instead
> of querying the resource resolver a lot, caching above the resolver
> would even avoid querying the resolver.

This turns out to be the best approach in my case. Especially since a
new ResourceResolver gets instantiated for each new request, which
makes it more difficult to add global caching.

However, since the resolution process depends on access rights, I
currently need to do something like this to include the potential
username in the cache key:

    String user = "";
    Session session = resourceResolver.adaptTo(Session.class);
    if (session != null) {
        user = session.getUserId();
    }

This seems a bit fragile, so I was wondering if getting the username
from the request would work better:

    String user = "";
    Principal principal = request.getUserPrincipal();
    if (principal != null) {
        user = principal.getName();
    }

I guess there are cases where the JCR Session (or whatever is used for
resource resolution) is authenticated using something else than the
user principal associated with the HTTP request.

Ultimately we should probably solve the performance issue on the
repository layer by making path lookups (especially negative ones)
blazingly fast. They're already pretty good in Jackrabbit, but for my
use case I'd need about an order of magnitude more performance. With a
simple high-level cache I was able to achieve this.

BR,

Jukka Zitting

Reply via email to