[Kolab-devel] Expiring Kolab objects cache in Roundcube

Thomas Brüderli bruederli at kolabsys.com
Sat Jun 9 14:39:04 CEST 2012


The new storage layer for Kolab 3.0 in Roundcube slowly grows up and it
also provides caching of Kolab objects in the local (My)SQL database. The
cache is persistent and synchronized with the IMAP mailbox on every access.
This means that all objects of each resource every accessed through the web
client have a copy in the local cache. You can easily imagine the growth of
that cache. So we need some strategy how to expire and remove cache objects
in a way that keeps good balance between access speed and storage volume.
Here are a few thoughts how that might be achieved:

1) Clear user's cache when a user terminates a session
2) Cronjob which removes cache objects older than T - <cache-lifetime>
3) Same as 2) but triggered randomly on web client requests (no cronjob)

Of course every one of these approaches has it's pros and cons. Even the
removal of objects being in cache for a long time isn't always desired.
Imagine contacts in an address book which is accessed daily. But that's
probably a trade-off we have to live with because on the other hand, the
web client will not be notified when a user is removed from the IMAP
backend and will therefore never access the cached objects again. So
removing objects added to the case some time ago is mandatory even if
they'll be re-added a short time after.

Also 1) isn't perfect for several reasons: this would require a complete
re-sync on every login which can easily take longer than just a few
seconds. And, even more important, caches are shared amongst users. If user
A has shared a folder with user B, its objects are only cached once and
both users access the same records. Thus clearing the cache when user A
logs out would cause user B's session to re-sync the entire folder.

I'd therefore propose either 2) or 3). Depending on how easy/complicated it
would be to install a cron job within the Kolab setup 2) would definitely
be better because it's entirely independent from web server requests. For
3) I had in mind to just call a decoupled shell command in order to not
block the http request which triggered the cache cleanup process.

Any comments are welcome!


More information about the devel mailing list