[Building Sakai] cache automatically updates itself?

Steve Swinsburg steve.swinsburg at gmail.com
Fri May 28 16:13:32 PDT 2010


Hi all,

I have a cache in my app that caches objects loaded from the database so that subsequent requests use the cached version and don't hit the database again.

On one of my pages I allow a user to update their own version of the object and it is saved to the database. What I am seeing however, is that this change is also reflected in the cached version, ie they are kept in sync. Is this normal behaviour? I haven't specifically coded for updates to be readded to the cache, I was just testing and noticed this was happening anyway.  I am not sure if it's expected behaviour so will explicitly update the cache with the updated verison when it's saved.

Some pseudocode of what I have at the moment:

getRecord(userId) {

   check cache
   if exists in cache, returned cached version

   if not get from db and add to cache for future lookups
}

updateRecord(object) {
   save object to db
}

So no explicit cache update in the updateRecord method, but it's happening anyway.

Any input on the Cache/MemoryService appreciated.

cheers,
Steve


More information about the sakai-dev mailing list