develth
develth

Reputation: 792

Symfony2 ACL Cache

Is there any example or better documentation about how to cache ACL Queries in Symfony2.

I found following:

http://api.symfony.com/2.0/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.html

But i do not exactly know how to apply this on my Checks.

Upvotes: 2

Views: 695

Answers (1)

jkrnak
jkrnak

Reputation: 956

I've managed to cache ObjectIdentities. Which is bit of a help but not much.

After a lot of digging around in the security*.xml files I've made the following modifications of the config.yml:

  • I've added cache id (Service id) to the ACL configuration
  • I've enabled Doctrine result cache.

config.yml:

doctrine:
    orm:
        result_cache_driver:
            type: apc

security:
    acl:
        cache:
            id:     security.acl.cache.doctrine
            prefix: my_acl_prefix_

This will only enable caching of ObjectIdentities, but a lot of other queries are happening when the Symfony\Component\Security\Acl\Dbal\AclProvider::getAncestorIds() is being called. That method directly executes an SQL query, and uses no cache. In 2.2 and 2.3 there is a comment in the method saying:

            // FIXME: skip ancestors which are cached

Same stands for a couple of other methods in that class in terms of not using result cache.

I guess by implementing your own AclProvider and injecting the entity manager's result cache you can cache these queries too.

Upvotes: 1

Related Questions