5

I'm implementing a Core Service "Facade" for some lazy programmers that don't want to change their coding style (me included), and wanted to implement object cache, which obviously leads to the grand question of "how long and how much should I cache".

The ideal answer is to cache forever except when data is changed.

Is there a way (via some WCF event perhaps) to implement a "listener" for data changes that could be used to remove items from their cache?

BTW, I am using .NET's native ObjectCache (MemoryCache) with a 1 minute sliding cache policy for now.

Thanks,

N

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42

1 Answers1

7

There is no such system built-into either WCF or Tridion that I know of.

You could of course roll your own, where you:

  1. Listen for changes to the relevant data on the TCM server with Event Handlers
  2. Have those event handlers forward the event to a central notification server
  3. Have your WCF clients register with that notification server when they start up
  4. Have notification server subsequently send the notifications on to the connected clients

This is essentially quite similar to how Tridion's Broker Object Cache works on the Content Delivery tier.

If you're interested in implementing such an approach, I'd suggest having a look at the Signalr project, which takes a lot of the hassle out of it.


Edit: it turns out WCF has something akin to what you're asking for called Callbacks. See this question and this blog post.

Community
  • 1
  • 1
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks Frank. At this point I'm a bit reluctant to add "one more" event to the system in question, I'll wait for it to stabilize first... The 1 minute cache will at least cover lazy programming (I may even reduce it further since the performance hits I've been seeing are caused by code reloading the same object collections over & over in different methods) – Nuno Linhares Jul 29 '12 at 14:14