JCS is a distributed caching system written in java. It is intended to speed up applications by providing a means to manage cached data of various dynamic natures. Like any caching system, JCS is most useful for high read, low put applications. Latency times drop sharply and bottlenecks move away from the database in an effectively cached system. Learn how to start using JCS.
The JCS goes beyond simply caching objects in memory. It provides numerous additional features:
JCS 2.0 works on JDK versions 1.6 and up. It only has a dependency on Commons Logging.
The foundation of JCS is the Composite Cache, which is the pluggable controller for a cache region. Four types of caches can be plugged into the Composite Cache for any given region: (1) Memory, (2) Disk, (3) Lateral, and (4) Remote. The Composite Cache orchestrates access to the various caches configured for use in a region.
The JCS jar provides production ready implementations of each of the four types of caches. In addition to the core four, JCS also provides additional plugins of each type.
The LRU Memory Cache is an extremely fast, highly configurable memory cache . It uses a Least Recently Used algorithm to manage the number of items that can be stored in memory. The LRU Memory Cache uses its own LRU Map implementation that is significantly faster than both the commons LRUMap implementation and the LinkedHashMap that is provided with JDK1.4 up. This makes JCS faster than its competitors .
The Indexed Disk Cache is a fast, reliable, and highly configurable swap for cached data. The indexed disk cache follows the fastest pattern for disk swapping. Cache elements are written to disk via a continuous queue-based process. The length of the item is stored in the first few bytes of the entry. The offset is stored in memory and can be reference via the key. When items are removed from the disk cache, the location and size are recorded and reused when possible. Every aspect of the disk cache is configurable, and a thread pool can be used to reduce the number of queue worker threads across the system.
The JDBC Disk Cache is a fast, reliable, and highly configurable disk cache. It stores both the keys and elements in a JDBC compatible database. The JDBC disk cache stores elements in a database as BLOBs. Periodically, the table is swept to remove expired elements. Multiple instances can be configured to use a common connection pool. A thread pool can be used to reduce the number of queue worker threads across the system. The MySQL version of the JDBC Disk Cache can optimize and repair tables.
The TCP Lateral Cache provides an easy way to distribute cached data to multiple servers. It comes with a UDP discovery mechanism, so you can add nodes without having to reconfigure the entire farm. The TCP Lateral Cache works by establishing connections with socket server running on other nodes. Each node maintains a connection to every other. Only one server is needed for any number of regions. The client is able to re-establish connections if it looses its connection with another server. The TCP Lateral is highly configurable . You can choose to only send data, to not look for data on other servers, to send removes instead of puts, and to filter removes based on hash codes.
JCS also provides an RMI based Remote Cache Server . Rather than having each node connect to every other node, you can use the remote cache server as the connection point. Each node connects to the remove server, which then broadcasts events to the other nodes. To maintain consistency across a cluster without incurring the overhead of serialization, you can decide to send invalidation messages to the other locals rather than send the object over the wire. The remote cache server holds a serialized version of your objects, so it does not need to be deployed with your class libraries. The remote servers can be chained and a list of failover servers can be configured on the client.
JCS is not a tag library or a web specific application. JCS is a general purpose caching system that can be used in web applications, services, and stand alone Java applications.
JCS is not a transactional distribution mechanism. Transactional distributed caches are not scalable. JCS is a cache not a database. The distribution mechanisms provided by JCS can scale into the tens of servers. In a well-designed service oriented architecture, JCS can be used in a high demand service with numerous nodes. This would not be possible if the distribution mechanism were transactional.
JCS does not use AOP. JCS is a high performance, non-invasive cache. It does not manipulate your objects so it can just send a field or two fewer over the wire.
JCS is not a fork, an offshoot, a branch, or any other derivation of JCS. Nor is JCS named after another library. JCS is a mature project that has been under development and in use since 2001. Over the years JCS has incorporated numerous bug fixes and has added dozens of features, making it the best designed and most feature rich caching solution available.