Home

raffaeleguidi edited this page Oct 6, 2011 · 98 revisions

DirectMemory logo


DirectMemory is now being incubated in Apache! Stay tuned for more exciting news at the official incubator site.

DirectMemory is a multi layered cache implementation featuring off-heap memory storage (a-la BigMemory) to enable caching of java objects without degrading jvm performance. Its main purpose is to act as a second level cache (after a heap based one) to collect large amounts of data without filling up the java heap and thus avoiding long garbage collection cycles. Included in the box is a small set of utility classes to easily handle off-heap memory buffers.

Although serialization makes things a bit slower (not too much, thanks to protostuff) put/get operations are in the sub-millisecond range being pretty acceptable in every usage scenario and, most of all, outperforms heap storage when the count of the entries goes over a certain number (see micro benchmark for reference). DirectMemory implements cache eviction based on a simple LRU (Least Recently Used) algorythm and also on item expiration (this are being reworked, and an LFU will be added as well). Latest release focuses on consolidating the core off-heap management and passes a base set of unit, performance and concurrency tests (using a junit-benchmarks). No binaries, yet, gotta use maven if you want to give it a try.

See this unit test for a usage example and this page to get started with DirectMemory (basic maven skills needed).

Features

  • The cache features an off heap memory store - usage data is collected to enable the future implementation of LRU and LFU eviction (these will be handled in a separated thread)
  • Utility classe to handle allocation of **multiple buffers (of max 2gb each) **. Locking is at single entry level is not needed as each and every entry has a dedicated "pointer" to the shared buffer
  • Two different serializers, standard java and protostuff (which allows for not "serializable" pojos) and uses ByteBuffers as well to further reduce heap usage.

Take also a look at DirectMemory FAQ for potential use cases and commonly asked questions.

Next steps and future plans:

  • Implementation of file based persistence (not realtime)
  • Implementation of memcached protocol (maybe using or merging with jmemcached?)
  • Implementation of cache distribution using **Hazelcast **or Terracotta
  • Contact me on twitter if you have suggestions or specific needs

References:

Source code and documentation released under the Apache Software License, Version 2.0