This project is read-only.

Cache signal triggering issues

Topics: Core, Troubleshooting, Writing modules
Jul 8, 2013 at 2:29 PM
Let us use the following example.

I have a list of data, that I cache. Whenever I modify the list, I trigger a signal to reset the cache.

All good and well, but the problem is this: the signal gets triggered BEFORE the end of the transaction. This can give issues if a visitor accesses the cached data again, since it would replenish the cache with stale data as the new data hasn't been committed yet.

Our client is running in this issue now from time to time IF the visitor replenishes the cache before the transaction is actually committed (it would be a race condition if it weren't for the fact that we get plenty of hits so it happens a lot)

We're now using ReadUncommitted as was adviced , and I guess this is the reason why this issue can occur.

How can I execute code after I KNOW the transaction was committed, since the issue would be resolved if I can trigger the signal AFTER the transaction is committed.

Or is there another way to resolve this issue?

BTW: Using 1.6
Jul 8, 2013 at 6:10 PM
Most of the time you don't want to wait like that, but I understand your case, which is an exception. What you can do is use the IProcessingEngine which will let you enlist tasks to happen after the web transaction is flushed, in its own transaction. Look for examples of usage in the code, should be easy for you.
Jul 9, 2013 at 7:38 AM
Thanks! That looks exactly like what I need :)