» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with 223 + 144

cache4j

cache4j is a cache for java objects. Simple API and fast implementation. * in memory caching * design for multithread environment * two implementation: synchronized, blocking * eviction algorithm LFU, LRU, FIFO * for store object can use strong or soft reference * available under the BSD license cache4j Tutorials http://cache4j.sourceforge.net/tutorial.htm Cache4j Download http://sourceforge.net/project/showfiles.php?group_id=160023&package_id=180807&release_id=399978 More Open Source Cache Systems

Java: Open Source Java(OpenJDK)

JBossCache - TreeCache

JBoss Cache is a replicated and transactional cache. It is replicated since multiple JBoss Cache instances can be distributed (either within the same JVM or across several JVMs whether they reside on the same machine or on different machines on a network) and data is replicated across the whole group. It is transactional because a user can configure a JTA compliant transaction manager and make the cache operation transactional. Note that the cache can also be run without any replication; this is the local mode. Currently, JBoss Cache consists of two components: a generic cache (implemented internally as org.jboss.cache.TreeCache) and a POJO cache (implemented internally as org.jboss.cache.aop.PojoCache). TreeCache is a tree-structured cache that provides replication and transaction context, while PojoCache extends the functionality of TreeCache but behaves as a true object cache providing transparent and finer-grained object mapping into internal cache. JBoss Cache is a product designed to cache frequently accessed Java objects in order to dramatically improve the performance of e-business applications. By eliminating unnecessary database access, JBoss Cache decreases network traffic and increases the scalability of applications. But JBoss Cache is much more than a simple cache. JBoss Cache provides fully transactional features as well as a highly configurable set of options to deal with concurrent data access in the most efficient manner possible for your application. In addition, it is a clustered cache that replicates contents to other cache instances running on separate JVMs, servers or even entire networks, making JBoss Cache a highly efficient library used by application server developers to implement clustering features. JBoss Cache provides two caching APIs to suit your needs. The JBoss Cache API offers a traditional, tree-structured, node-based cache and the Pojo Cache API, which builds on the JBoss Cache API, provides the ability to perform object-based, fine-grained replication of Java objects, resulting in maximum performance benefits. Please see the JBoss Cache user guide for a more detailed discussion on these APIs. What is the license for JBoss Cache? JBoss Cache is licensed under LGPL How do I build JBoss Cache from CVS sources? To build, do sh build.sh jar. This will produce jboss-cache.jar in the dist/lib directory. Or if you want to build the standalone package, do sh build.sh dist this will produce dist/jboss-cache-dist.zip Note that you will need to use JDK 5.0 to build the distribution. You can still use the binaries you build with J2SE 1.4.x though.. Can I run JBoss Cache outside of JBoss Application Server? Of course! JBoss Cache comes in two flavors: * Integrated with JBoss Application Server as an MBean service. * Standalone, that can run in any Java EE server such as BEA WebLogic or IBM Websphere. Of course, it can also run in a standalone Java process (i.e., outside Java EE context). How do I deploy JBoss Cache as a MBean service? To deploy JBoss Cache as an MBean inside JBoss, you can copy the configuration xml file over to the deploy directory (from all configuration whereby the necessary jars are present). Under the standalone package etc/META-INF directory , there are example configuration files for different cache modes that can be used to deploy JBoss Cache as well. How does JBoss Cache's replication mechanism work? JBoss Cache leverages JGroups as a replication layer. A user can configure the cluster of JBoss Cache instances by sharing the same cluster name (cluster name). There is also an option of whether to populate the cache data upon starting a new instance in the ClusterConfig attribute. Note that once all instances join the same replication group, every replication change is propagated to all participating members. There is no mechanism for sub-partitioning where some replication can be done within only a subset of members. This is on our to do list. Which TransactionManagers are supported by JBoss Cache? JBoss Cache supports any TransactionManager that is JTA compliant such as JBossTM. A user can configure the transaction manager through the configuration xml setting. JBossCache also has a built in dummy transaction manager (org.jboss.cache.tm.DummyTransactionManager) for testing purposes only. But note that DummyTransactionManager is not thread safe .i.e., it does not support concurrent transactions. Instead, only one transaction is allowed at a time. Download JBoss Cache http://labs.jboss.com/jbosscache/download/index.html JBoss Cache Documentation http://labs.jboss.com/jbosscache/docs/index.html

Java: Open Source Java(OpenJDK)

ShiftOne Java Object Cache

ShiftOne Java Object Cache is a Java library that implements several strict object caching policies, decorators that add behavior, and a light framework for configuring them for an application. It's strict in that each cache enforces two limits in a very strict and predictable way. # Max Size - each cache has a hard limit on the number of elements it will contain. When this limit is exceeded, the least valuable element is evicted. This happens immediately, on the same thread. This prevents the cache from growing uncontrollably # Element Timeout - each cache has a maximum time that it's elements are considered valid. No element will ever be returned that exceeds this time limit. This ensures a predictable data freshness. Currently, First In First Out (fifo), Least Recently Used (lru), and Least Frequently Used (lfu) caching policies are implemented. These are refered to as policy caches. They are responcible for holding onto the data in the cache. ShiftOne Features Features are added by wrapping policy caches with "decorators". When a decorator is configured for a cache, your application operates on the decorator cache, which delegates to a policy cache. Behavior is configured by linking several decorators in front of a policy cache. Support includes: # Monitoring and instrumentation with JMX # Clustering using JGroups or JMS # Hit/Miss statistics reporting # Memory sensitivity using soft references # Hibernate ORM integration (adaptor) There are also a number of adaptors that allows a cache to take on another interface. How is a cache obtained? This cache implementation strives to abstract from an application, the concrete implementation and configuration of a cache. For this reason, cache's should be accessed exclusively using the "Cache" interface (cache policies are not public classes, so this is required). Both caches and cache factories may be obtained from a cache configuration. A cache configuration allows mnemonic names to be associated with various cache and factory configurations. If an application absolutely needs to programmatically set the max size and timeout of a cache, then a cache factory should be obtained from the config first, and used to create a cache. Why was this implemented? JOCache was originally implemented as part of the ExQ project to support ResultSet caching. It was later split out for use by other projects. It was designed to cache large expensive database query results. ShiftOne Project Home Page http://jocache.sourceforge.net/ Download ShiftOne http://sourceforge.net/project/showfiles.php?group_id=67753 ShiftOne API Documentation http://jocache.sourceforge.net/api/index.html

Java: Open Source Java(OpenJDK)

SwarmCache - Cluster-aware Caching for Java

SwarmCache is a simple but effective distributed cache. It uses IP multicast to efficiently communicate with any number of hosts on a LAN. It is specifically designed for use by clustered, database-driven web applications. Such applications typically have many more read operations than write operations, which allows SwarmCache to deliver the greatest performance gains. SwarmCache uses Java Community internally to manage the membership and communications of its distributed cache. Wrappers have been written that allow SwarmCache to be used with the Hibernate and JPOX persistence engines. How It Works? The concept behind SwarmCache is fairly simple. Each server instantiates its own manager. For each type of object that the server wishes to cache, it instantiates a cache and adds it to the manager. The manager joins a multicast group and communicates with other managers in the group. Whenever an object is removed from a cache, the manager notifies all other managers in the group. Those managers then ensure that the object is removed from their respective caches. The result is that a server will not have in its cache a stale version of an object that has been updated or deleted on another server. Note that the managers only need to communicate when an object is removed from a cache. This only happens when an object is updated or deleted. The managers do not co-operate beyond this. This means that the amount of inter-server communications is proportional to the amount of updates/deletes of the application. As the communications is multicast, it is not proportional to the number of caching hosts. Also notice that there is no "server"; all hosts are equal peers and they can come and go from the cache group as they please without affecting other group members. Thus the operation of the distributed cache is very robust. Basic Usage SwarmCache is designed to be integrated in to the persistence layer of a database-driven Java application. However, it could be useful for other types of applications. Once built in to the persistence engine, SwarmCache should be transparent to higher layers of the software. SwarmCache does not directly support transaction management. This can be accomplished by wrapping the cached objects and storing some additional transaction data. This will described and possibly implemented at a later date. Swarmcache requires that swarmcache.jar, jgroups-all.jar, commons-collections.jar, and commons-logging.jar (included in the download) be in your classpath. For most applications, it is sufficient to make use of the CacheFactory class to configure and use SwarmCache. Here is an example: import net.sf.swarmcache.*; ... CacheFactory cacheFactory; ... // Configure and Initialize the cache manager CacheConfiguration conf = new CacheConfiguration(); conf.setCacheType(CacheConfiguration.TYPE_LRU); cacheFactory = new CacheFactory(conf); ... // Create a new cache, using a name that describes // what kind of object we will store ObjectCache cache = cacheFactory.createCache("People"); ... // Store something in the cache String key = "0001"; String person = "John Watkinson"; cache.put(key, person); ... // Retrieve something from the cache String person = (String)cache.get("0001"); System.out.println(person); ... // Clear an object from the cache // (This results in the sending of a // multicast message to other caching hosts) cache.clear("0001"); String person = (String)cache.get("0001"); // The following will print 'null' System.out.println(person); The example is simple, but running this same code on multiple machines in a network will result in their caches being consistent. Note that the keys used must be serializable objects-- they must implement java.io.Serializable. The objects themselves that are stored in the cache need not be serializable. And of course, the keys should not be large objects for transmission efficiency purposes. In order to keep keys distinct, it is usually preferred to have one cache per type of object stored. In that case, it makes sense to follow the convention that the cache be named after the fully-qualified class name of the object type to be stored. Usage in a Persistence Engine Here is some skeleton code that demonstrates how SwarmCache could be integrated in to a persistence engine. The following class is responsible for persisting an object of type Person: public class PersonEntity extends GenericEntity { ObjectCache cache; public PersonEntity(CacheFactory cacheFactory) { cache = cacheFactory.createCache("Person"); // * Other initialization here } ... public Person get(long key) { Long cacheKey = new Long(key); Person person = (Person)cache.get(cachekey); if (person == null) { // * Get the object from the database if (person != null) { // Put it in the cache cache.put(cacheKey, person); } } return person; } ... public void insert(Person person) { // * Do database insert // Add new object to cache Long cacheKey = new Long(person.getKey()); cache.put(cacheKey, person); } ... public void update(Person person) { // * Do database update // Remove object from cache // (This causes all caches in the group to be notified) Long cacheKey = new Long(person.getKey()); cache.clear(cacheKey); // Re-add the object to the cache cache.put(cacheKey, person); } ... public void delete(long key) { // * Do database delete // Remove object from cache // (This causes all caches in the group to be notified) Long cacheKey = new Long(key); cache.clear(cacheKey); } ... } SwarmCache Project Home Page http://swarmcache.sourceforge.net SwarmCache Documentation http://swarmcache.sourceforge.net/documentation.html Download SwarmCache http://sourceforge.net/project/showfiles.php?group_id=78637&release_id=193220 Permalink

Java: Open Source Java(OpenJDK)