Best way to store cache in DB object memory in Silverlight

I would like to configure the cache of database objects (i.e. rows in a table) in memory in silverlight, which I will do using WCF and linq-to-sql. When I have objects in memory, I plan to use MSMQ to retrieve new objects whenever they are changed. This is a somewhat complicated approach, but the goal is to reduce database travel and provide instant data transfer between Silverlight applications connected to MSMQ.

My Silverlight applications are designed for a long time, and the amount of data that will be cached will be small. I plan to keep the cache in memory using local storage.

In any case, in order to handle updated objects that come in, I would like to know if the user has modified an existing object. Can I use some kind of data binding event to set a flag indicating that the object is changing?

Maybe the best thing is to make a cache?

Thanks!

+4
source share
2 answers

I think a little more clarification is required to understand your requirements. Some of the things you say are obscure or even contradictory. However, a few general thoughts:

  • If the amount of data in the cache is not large, I would not worry about local storage - I would just save it in some area of ​​the application (global variable, application context, etc.). If the application restarts, the cache will need to be pulled out of the database fresh (I would suggest that this would be desirable anyway).

  • Typically, objects that are cached are read-only (cannot be modified by the user). If the user modifies the object that will be cached, you will usually want to immediately save this information on the server / database so that other clients can get this information.

  • If the server / database stores the "main" cached data and should notify clients in case of data changes, the Silverlight application most likely should be a subscription listener for some service (MSMQ can actually work as a back end). If updates do not need to be in real time, consider that the cache is just updated on a timer every 5-10 minutes or so.

+3
source

There are many examples that use duplex WCF services (via HTTP) - perhaps looking for implementations of publish / subscribe templates for Silverlight will give you a start.

Admittedly, I can’t provide an approximate implementation for your scenario, but there are some places worth looking at:

Laharsub: PollingDuplexHttpBinding Real-Time Web Application Message Server and Publishing a Subscription Framework

+2
source

Source: https://habr.com/ru/post/1338939/


All Articles