Zimbra Message Cache

E-Mail Content Caching in Zimbra

Nil Seri
2 min readJan 26, 2021
Photo by Tom Winckels on Unsplash

About Zimbra Message Cache:

From https://wiki.zimbra.com/wiki/Message_Cache:

The uncompressed file cache stores uncompressed versions of blobs on disk. The first time a compressed blob is accessed, we write the uncompressed version to /opt/zimbra/data/tmp/uncompressed. When the file descriptor is closed or aged out of the file descriptor cache, we remove the associated blob from the uncompressed cache. The cache is cleared during server startup and shutdown.

https://github.com/Zimbra/zm-mailbox/blob/90cf9a8ebe8cd5a09068b2ced1b185f05c9406e5/store/src/java/com/zimbra/cs/mailbox/MessageCache.java

If the size is under MESSAGE_CACHE_DISK_STREAMING_THRESHOLD value (please see the code link above), it tries to read it from local cache. If it does not exist there, it reads from the object store. If the size is above this threshold value, it reads from the object store in either case.

From “getContent” in the upper code, it goes inside https://github.com/Zimbra/zm-mailbox/blob/develop/store/src/java/com/zimbra/cs/store/external/ExternalStoreManager.java to the method below. From there, “readStreamFromStore” method is called. If you had implemented your own object store extension, this will be the code you have written (for coding Zimbra extensions, you can visit my post here) to read mail files from your object store. As you can see, before this method is called, its existence in cache is checked first.

When Zimbra starts up, cache is initialized. For “uncompressed”, max files, max bytes and min lifetime values are set.

https://github.com/Zimbra/zm-mailbox/blob/develop/store/src/java/com/zimbra/cs/store/external/ExternalStoreManager.java startup() method:

The parametric values above are in https://github.com/Zimbra/zm-mailbox/blob/90cf9a8ebe8cd5a09068b2ced1b185f05c9406e5/common/src/java/com/zimbra/common/localconfig/LC.java. These values can be changed with Zimbra config set commands.

Inside https://github.com/Zimbra/zm-mailbox/blob/90cf9a8ebe8cd5a09068b2ced1b185f05c9406e5/common/src/java/com/zimbra/common/util/Constants.java:

https://github.com/Zimbra/zm-mailbox/blob/90cf9a8ebe8cd5a09068b2ced1b185f05c9406e5/common/src/java/com/zimbra/common/util/FileCache.java, FileCache class comment here says:

Happy Coding!

--

--

Nil Seri

I would love to change the world, but they won’t give me the source code | coding 👩🏻‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨