zircote.com

development (in)action

Zend_Acl Storage With Redis

Recently I have been playing around with Rediska and Zend_Acl looking at different ways to store the lists and manipulate them so I put together a few of my scribbles to share.

Requirements:

This basic demonstrate support for multiple containers, utilizes a singleton for creation of each container. The creation of nonexistent acl containers within redis is delegated to the Rediska_Key::getOrSetValue method for initialization of the redis key being requested. This method uses the Acls name (‘BugsService’) through ReflectionClass to locate the proper creation controls.

SomeAclService::getInstance($aclName) returns the RediskaAcl container with name: $aclName.

RediskaAcl extends Zend_Acl, providing methods: getAcl() returns the object, creating the object and saving to the redis namespace if it does not exist setAcl(), allows a manual save of the current Acl in the event it is modified. setRedis() allows for run time Rediska instance configuration.

Model_BugsServiceAcl provides the mechanisms by which first time creation of the Acl is realized, this may be a Mapper to the database models that would generate the Acl and return the RediskaAcl object that is then saved to the redis namespace.

RedisAclTest demonstrates the use and verification of proper functionality of the Acl roles and resources.

Finally a short example of runtime usage