Just wondering how you guys manage your cache invalidations. Given that there might objects (hundreds and thousands) in the cache that might be triggered by different algorithms or rules. How do you keep track of it all?
I'm not sure to understand clearly this part but I think that you should define different "regions" (like in Hibernate terminology), each with its own content and rules.
Is there anyway you can reference the relationships from a table in the database and enforce it somehow?
The persistence layer is the best place to do this in my opinion as it is aware of what is happening with persistent and potentially cached entities. Hibernate, for example, supports (second level) caching and allows to define the name of the second level cache region, the caching strategy (read-only, read-write, nonstrict-read-write, transactional) per entity. Hibernate actually define an interface and allows to plug a cache implementation, depending on your needs (the cache type, the supported strategies, the cluster support).
Do bear with me as I've never done any caching before.
Depending on the complexity of your needs, this might not be a simple task. Maybe you should use or look at existing solutions. In the Java world, EHCache, OSCache, SwarmCache, JBoss Cache 2 are invalidating caches (or support it). This is just a suggestion as you didn't mention any language.