Events and Behavior without an instance

Hi,

I posted a request about needing a solution for transparent cache handling. This rised another question. Maybe someone can help me with this.

Here is what I like to do. I activated Query Caching and implemented an own CacheDependency class. This class saves alle tables that are in the cache in a global variable. I can not get the information what tables and queries are stored from the cache itself, since the key is generated by the class CDbCommand itself without providing this information.

Everything works fine.

Now I like to delete the entry from the global variable (therefore from the cache) if a value in a table is changed that is in the cache. I like to implement this behavior transparent. It should to do without modifing the base classes or implementing another class that every model has to extend. The only way to do this, is to use the CacheDependency class.

I have in mind that a model throws an onAfterSave event that the CacheDependency class is notified by and therefore take the nessaccary actions in the cache.

But I do not find a solution to define the CacheDependency globally and attaching a method of this class that is called when an object is saved. In Java it is not a problem. In Yii it looks like that I am only able to attach a handle to an instance.

Does anyone has an idea how to overcome this limitation?

Thanks in advance,

Danny