views:

78

answers:

1

I have this scenario: I have a chain of query handlers, the first is to query the cache, if the cache can't answer it or the answer is stale, then hit a database, if it can't find the answer or the answer is stale again, then query a remote web service.

But I am not sure if this is the right way to use this pattern, since the work flow is pretty much fixed, and the cache and database handlers depend on the next step's return result to refresh its records.

+1  A: 

What you're referring to is not, strictly speaking, the chain of responsibility pattern. It sounds more like you're implementing a cache. If you are implementing a cache, then the scenario you describe is fine. If you're looking for true chain of responsibility though, it isn't.

Billy ONeal