Dec 4 2006

WCF and caching with a dash of IOperationBehavior

Category: IT Related | .NetRory Primrose @ 07:16

I have been looking at caching support and WCF recently. I have come across a few solutions. These are:

  1. Calling through HttpRuntime to get at the ASP.Net cache
  2. Using Enterprise Library Caching Block
  3. Rolling your own implementation, usually storing data in a Dictionary<String, Object> collection.

I have problems with 1 because that ties your WCF service down to an IIS and HTTP solution which is not good design. Option 3 is also not that great because typically this is built as a 'quick and dirty' solution that doesn't support any cache dependency or cache expiration policies. I haven't played with 2 yet, but it looks like that will be the go.

On a side note, I came across a code sample by Scott Mason (where's the blog Scott???) that uses an IOperationBehavior implementation to hook the operation call to provide caching support outside the actual implementation of the service operation. This is a great idea. The only thing I don't like about it is that operation behaviors can't be set via application configuration. They can only be assigned to an operation (WCF method) via a custom attribute on the method or via the behaviors collection at runtime. Pity, it would be so nice if you could plug in different behaviors via configuration.

Tags:

Comments (1) -

1.
Dev Dev United States says:

Hi there..

the code sample by Scott Mason.. that you mentioned.. looks like the site is down. Do you have the code sample that was given there? can you pls add it to your post?

Thanks

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading