A Fractional Key System for Memcache.
Fragmented or as I prefer to call them fractional keys provide a relatively trouble free way of managing the inter-dependencies of cached data.
At its heart fractional keys are simply tag based keys. Where they differ from the standard implementation of tag based keys is that each tag has an associated version number. This allows us to invalidate all keys dependent on a specific tag automatically by incrementing its associated version.
I think we’ve all gotten sick of keeping track of arguments lists for certain functions and suddenly felt the desire to resort to named params in order to avoid messes such as functions that look like
foo(array $argot, ingot $begot,ingot $cargot, cat $dargot,$ergot,$farthing,$garging,$haring,$baonr,$tarish = 4 ,$smar = "lare",$lar = null,$var = smare, $snare= gare);
The simplicity of
foo($params);
is clear, especially if many or all of our named params have default values and do not need to be passed in explicitly.
One of the beauties of our current generation of languages is the retirement of the dependency diamond and all of the other oddities that multiple inheritance can wreak on unwary developers. Multiple Implementation of Interfaces is much preferable to multiple inheritance for many reasons, but throwing all caution to the wind lets say we did desire some way to mimic multiple inheritance within php?
Building on my pseudo decorator class I have written a class that allows us to encapsulate multiple third party objects within our “decorator” class. Essentially with this Union class we can mimic multiple inheritance.
The Decorator Pattern allows us to easily change the methods and attributes of an object at runtime. Here is my source code for a psuedo decorator class which silently passes attribute and method calls down to its encapsulated object.
This is not strictly an example of the decorator pattern as our encapsulating class is not inherited from our encapsulated class; however, this does provide a useful way to quickly wrap third party objects and shows some of the logic (the calling of the encapsulated methods & members) one may want to employ if actually deriving a decorator class from a base class.

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 