Cache Frequently Asked Questions

JBoss Enterprise Application Platform 5

for Use with JBoss Enterprise Application Platform 5

Edition 5.2.0

Ben Wang

Bela Ban

Manik Surtani

Scott Marlow

Galder Zamarreño

Edited by

Eva Kopalova

Edited by

Laura Bailey

Edited by

Petr Penicka

Edited by

Russell Dickenson

Edited by

Scott Mumford

Abstract

This book is a compilation of frequently asked questions about JBoss Cache for use with JBoss Enterprise Application Platform 5 and its patch releases.
JBoss Cache is deprecated

JBoss Cache is deprecated and will be removed in a future major release of JBoss Enterprise Application Platform.

Chapter 1. General Information

Q: What is JBoss Cache?
Q: Who are the JBoss Cache developers?
Q: How do I know the version of JBoss Cache that I am using?
Q: How can I migrate my application and configuration from using JBoss Cache 1.x to 2.x?
Q: What about from 2.x to 3.x?
Q:
What is JBoss Cache?
A:
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 any cache interaction transactional, and caches would participate in ongoing JTA transactions. Note that the cache can also be run without any replication; this is the local mode.
JBoss Cache comes in two flavors: Core and POJO versions. The core library (using the org.jboss.cache.Cache interface) is the underlying library that organizes data in a tree-like structure and handles all locking, passivation, eviction and replication characteristics of data in the cache. The POJO library (using the org.jboss.cache.pojo.PojoCache interface) is built atop the core library and allows introspection of objects in the cache providing transparent coherence by using JBoss AOP. Note that the POJO edition of JBoss Cache (often referred to as POJO Cache) comes with a separate set of documentation (POJO Cache User Guide, FAQ, etc.) available on the JBoss Cache documentation website.
Q:
Who are the JBoss Cache developers?
A:
JBoss Cache has an active community of developers and contributors. The project was founded by Bela Ban and is currently led by Manik Surtani. Jason Greene is the lead for the POJO Cache subsystem, and other contributors both past and present include Ben Wang, Harald Gliebe, Brian Stansberry, Vladimir Blagojevic, Mircea Markus, Jimmy Wilson, Galder Zamarreño and Elias Ross.
Q:
How do I know the version of JBoss Cache that I am using?
A:
java -jar jbosscache-core.jar will print version details.
Q:
How can I migrate my application and configuration from using JBoss Cache 1.x to 2.x?
A:
Look at this wiki page for help.
Q:
What about from 2.x to 3.x?
A:
JBoss Cache 3.x is API compatible with 2.x, although as far as possible you should refactor your code not to use deprecated methods as these may disappear in future releases of JBoss Cache.
JBoss Cache 3.x comes with an all new configuration format. Old 2.x configuration files will still work, although you will get a warning in the logs about this. Again, as far as possible, we recommend migrating your configuration file to the new format. Scripts are provided with the JBoss Cache 3.x distribution to migrate configuration files (see config2to3.sh and config2to3.bat).
Note that to take advantage of some of the new features in JBoss Cache 3.x, you need to be using the new configuration format.

Chapter 2. JBoss Cache: Core

Q: Can I run multiple JBoss Cache instances on the same VM?
Q: Can JBoss Cache run as a second level cache inside Hibernate?
Q: What about using POJO Cache as a Hibernate cache?
Q: How can I configure JBoss Cache?
Q: Can I use a schema or DTD to validate my JBoss Cache configuration file?
Q: What is the difference between the different cache modes?
Q: How does JBoss Cache's replication mechanism work?
Q: I run a 2-node cluster. If the network dies, do the caches continue to run?
Q: Can I plug in library X instead of JGroups to handle remote calls and group communications?
Q: Does the cache need to replicate to every other instance in the cluster? Is not this slow if the cluster is large?
Q: I'm using Buddy Replication. Do I need to have some form of session affinity?
Q: If I have the need for different configuration properties (e.g., CacheMode and IsolationLevel), do I simply need to create multiple org.jboss.cache.Cache instances with the appropriate configuration?
Q: Is not this expensive from a networking standpoint, i.e., needing to create sockets for each org.jboss.cache.Cache instance?
Q: Does the ClusterName configuration element have any relation to the EAP cluster PartitionName?
Q: When using multiple JGroups based components (cluster-service.xml, cache [multiple instances]), what is the correct/valid way to configure those components to make sure my multicast addresses do not conflict?
Q: Does JBoss Cache support cache persistence storage?
Q: Does JBoss Cache support cache passivation/overflow to a data store?
Q: Is JBoss Cache thread safe?
Q: Does JBoss Cache support XA (2PC) transactions now?
Q: Which transaction managers are supported by JBoss Cache?
Q: How do I set up the cache to be transactional?
Q: How do I control the Cache locking level?
Q: How does JBoss Cache lock data for concurrent access?
Q: How do I enable Optimistic Locking or MVCC in JBoss Cache?
Q: Can I use the cache locking level even without a transaction context?
Q: Does JBoss Cache support SELECT FOR UPDATE semantics?
Q: With replication (REPL_SYNC/REPL_ASYNC) or invalidation (INVALIDATION_SYNC/INVALIDATION_ASYNC), how often does the cache broadcast messages over the network?
Q: How can I do a mass removal?
Q: Can I monitor and manage the JBoss Cache?
Q: JBoss Cache uses a ":" character in its object name. This causes problems with my MBean server. What can I do about it?
Q: Can I disable JBoss Cache management attributes?
Q: What happened to jboss-serialization.jar?
Q: Does JBoss Cache support partitioning?
Q: Does JBoss Cache handle the concept of application classloading inside, say, a Java EE container?
Q: Does JBoss Cache currently support pre-event and post-event notification?
Q: How do I implement a custom listener to listen to cache events?
Q: Can I use the UseRegionBasedMarshalling attribute in JBoss Cache in order to get around ClassCastExceptions happening when accessing data in the cache that has just been redeployed?
Q:
Can I run multiple JBoss Cache instances on the same VM?
A:
Yes. There are some scenarios where you may want to run multiple instances of JBoss Cache. For example, you want to run multiple local cache instances with each instance having its own configuration (e.g., different cache policy). In this case, you will need multiple xml configuration files.
Q:
Can JBoss Cache run as a second level cache inside Hibernate?
A:
Yes. Since Hibernate 3.0 release, you can configure it to use JBoss Cache as a second level cache. For details, see Hibernate documentation, and also see this wiki page.
JBoss Cache 3.x with MVCC in particular works very well as a Hibernate second level cache.
Q:
What about using POJO Cache as a Hibernate cache?
A:
It is not necessary to use POJO Cache for second level cache inside Hibernate because Hibernate manages fine-grained fields in Java objects. Using POJO Cache will not provide any advantage, and will be an unnecessary performance drawback.
Q:
How can I configure JBoss Cache?
A:
You can configure the JBoss Cache through a configuration XML file or programmatically using a org.jboss.cache.config.Configuration object, passed in to the org.jboss.cache.CacheFactory instance.
Q:
Can I use a schema or DTD to validate my JBoss Cache configuration file?
A:
As of JBoss Cache 3.x, yes. An XSD schema is provided in your jbosscache-core.jar file, and is also available online, on http://www.jboss.org/jbosscache/jbosscache-config-3.0.xsd. You can configure your IDE, text editor or XML authoring tool to use this schema to validate your file.
Q:
What is the difference between the different cache modes?
A:
JBossCache has five different cache modes, i.e., LOCAL, REPL_SYNC, REPL_ASYNC, INVALIDATION_SYNC and INVALIDATION_ASYNC. If you want to run JBoss Cache as a single instance, then you should set the cache mode to LOCAL so that it will not attempt to replicate anything. If you want to have synchronous replication among different JBoss Cache instances, you set it to REPL_SYNC. For asynchronous replication, use AYSNC_REPL. If you do not wish to replicate cached data but simply inform other caches in a cluster that data under specific addresses are now stale and should be evicted from memory, use INVALIDATION_SYNC or INVALIDATION_ASYNC. Synchronous and asynchronous behavior applies to invalidation as well as replication.
Note that REPL_ASYNC and INVALIDATION_ASYNC are non-blocking. This can be useful when you want to have another JBoss Cache serving as a mirror or backup and you do not want to wait for confirmation that this mirror has received your messages.
Q:
How does JBoss Cache's replication mechanism work?
A:
JBoss Cache leverages JGroups for network communications. A JGroups configuration section is present in your JBoss Cache configuration.
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, unless you use the Buddy Replication features. See the JBoss Cache User Guide for more details on this.
Q:
I run a 2-node cluster. If the network dies, do the caches continue to run?
A:
Yes, both will continue to run, but depending on your replication mode, all transactions or operations may not complete. If REPL_SYNC is used, operations will fail while if REPL_ASYNC is used they will succeed. Even if they succeed though, caches will be out of sync.
Q:
Can I plug in library X instead of JGroups to handle remote calls and group communications?
A:
At this stage the answer is no. We do have an abstraction layer between the communication suite and JBoss Cache in the pipelines, and this may appear as a feature at some stage in the future.
Q:
Does the cache need to replicate to every other instance in the cluster? Is not this slow if the cluster is large?
A:
Replication need not occur to every node in the cluster. This feature - called Buddy Replication - allows each node to pick one or more 'buddies' in the cluster and only replicate to its buddies. This allows a cluster to scale very easily with no extra impact on memory or network traffic with each node added.
See the Users' Guide for more information on Buddy Replication, and how it can be used to achieve very high scalability.
Q:
I'm using Buddy Replication. Do I need to have some form of session affinity?
A:
Session affinity relates to returning to the same cache instance for the same data being used. While this is strictly not a requirement for Buddy Replication, it is greatly recommended to minimize moving state around a cluster.
Q:
If I have the need for different configuration properties (e.g., CacheMode and IsolationLevel), do I simply need to create multiple org.jboss.cache.Cache instances with the appropriate configuration?
A:
Yes. All the above mentioned properties are per cache instance. Therefore you will need separate org.jboss.cache.Cache instances.
Q:
Is not this expensive from a networking standpoint, i.e., needing to create sockets for each org.jboss.cache.Cache instance?
A:
Yes, it can be. For such cases it is recommended that you configure your cache using the JGroups Multiplexer, which allows several caches to share a single JGroups channel. Please see the Users' Guide for details on how to configure the JGroups Multiplexer.
A faster and more efficient approach is to use a shared transport in JGroups. Please see the JGroups documentation for more details on how to do this.
Q:
Does the ClusterName configuration element have any relation to the EAP cluster PartitionName?
A:
Yes. They are both JGroups group names. Besides the notion of a channel in JGroups, it also can partition the channel into different group names.
Q:
When using multiple JGroups based components (cluster-service.xml, cache [multiple instances]), what is the correct/valid way to configure those components to make sure my multicast addresses do not conflict?
A:
There are two parameters to consider: multicast address (plus port) and the group name. At minimum, you will have to run components using a different group name. But whether to run them on the same channel depends upon whether the communication performance is critical for you or not. If it is, then it'd be best to run them on different channels.
Q:
Does JBoss Cache support cache persistence storage?
A:
Yes. JBoss Cache has a cache loader interface that supports cache persistence. See below for more FAQs on cache loaders.
Q:
Does JBoss Cache support cache passivation/overflow to a data store?
A:
Yes. JBoss Cache uses the cache loader to support cache passivation/ overflow. See documentation on how to configure and use this feature.
Q:
Is JBoss Cache thread safe?
A:
Yes, it is thread safe.
Q:
Does JBoss Cache support XA (2PC) transactions now?
A:
No, although it is also on our to do list. Our internal implementation does use a procedure similar to 2PC to coordinate a transactions among different instances, but JBoss Cache is not an XA resource.
Q:
Which transaction managers are supported by JBoss Cache?
A:
JBoss Cache supports any TransactionManager that is JTA compliant such as JBoss Transactions.
While JBoss Cache does ships with a dummy transaction manager (org.jboss.cache.transaction.DummyTransactionManager), we do not recommend using this for production. It is not thread safe, and is intended for internal testing only.
Q:
How do I set up the cache to be transactional?
A:
You either use the default transaction manager that ships with EAP or you have to implement the org.jboss.cache.transaction.TransactionManagerLookup interface, and return an instance of your javax.transaction.TransactionManager implementation. The configuration property TransactionManagerLookupClass defines the class to be used by the cache to fetch a reference to a transaction manager. It is trivial to implement this interface to support other transaction managers. Once this attribute is specified, the cache will look up the transaction context from this transaction manager.
The org.jboss.cache.transaction.GenericTransactionManagerLookup class that ships with JBoss Cache is able to detect and bind to most popular transaction managers. See the GenericTransactionManagerLookup Javadocs for more information.
Q:
How do I control the Cache locking level?
A:
JBoss Cache lets you control the cache locking level through the transaction isolation level. This is configured through the attribute IsolationLevel. The transaction isolation levels correspond to database isolation levels, namely NONE, READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, and SERIALIZABLE. Note that these isolation levels are ignored if optimistic locking is used. For details, please refer to the JBoss Cache User Guide.
As of JBoss Cache 3.x, when using the MVCC locking scheme, only READ_COMMITTED and REPEATABLE_READ are supported. Any other isolation level provided will either be upgraded or downgraded accordingly.
Q:
How does JBoss Cache lock data for concurrent access?
A:
In JBoss Cache 2.x, by default pessimistic locking is used to lock data nodes, based on the isolation level configured. We also offer optimistic locking to allow for greater concurrency at the cost of slight processing overhead and performance. See the documentation for a more detailed discussion on concurrency and locking in JBoss Cache.
In JBoss Cache 3.x, optimistic and pessimistic locking are deprecated in favor of MVCC (multi-version concurrency control), which is far more efficient than either optimistic or pessimistic locking. For a detailed discussion on our MVCC implementation, see this blog entry and this wiki page.
Q:
How do I enable Optimistic Locking or MVCC in JBoss Cache?
A:
Please see the configuration section of the JBoss Cache User Guide for details.
Q:
Can I use the cache locking level even without a transaction context?
A:
Yes. JBoss Cache controls the individual node locking behavior through the isolation level semantics. This means even if you do not use a transaction, you can specify the lock level via isolation level. You can think of the node locking behavior outside of a transaction as if it is under transaction with auto_commit on.
Q:
Does JBoss Cache support SELECT FOR UPDATE semantics?
A:
Yes, but this is only possible if you are running within a JTA transaction and are using either MVCC or PESSIMISTIC as your node locking scheme.
To achieve SELECT FOR UPDATE semantics, simply do:
// start transaction ... 

cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
Node n = cache.get("/a/b/c"); // this acquires a WRITE LOCK on this node
    ...
    ...

// end transaction
Q:
With replication (REPL_SYNC/REPL_ASYNC) or invalidation (INVALIDATION_SYNC/INVALIDATION_ASYNC), how often does the cache broadcast messages over the network?
A:
If the updates are under transaction, then the broadcasts happen only when the transaction is about to commit (actually during the prepare stage internally). That is, it will be a batch update. However, if the operations are not under transaction context, then each update will trigger replication. Note that this has performance implications if network latency is a problem.
Q:
How can I do a mass removal?
A:
If you do a cache.removeNode("/myroot"), it will recursively remove all the entries under "/myroot".
Q:
Can I monitor and manage the JBoss Cache?
A:
Yes, using a JMX console such as the one shipped with EAP or JDK 5's jconsole utility. See the chapter titled Management Information in the JBoss Cache User Guide for more details.
Q:
JBoss Cache uses a ":" character in its object name. This causes problems with my MBean server. What can I do about it?
A:
This is something we have seen with some MBean servers. By default, JBoss Cache uses jboss.cache:service=JBossCache as a prefix to all objects it binds in JMX. To work around this, use the -Djbosscache.jmx.prefix JVM parameter to pass in an alternate prefix.
Q:
Can I disable JBoss Cache management attributes?
A:
Yes, you can. See the section on configuration in the JBoss Cache User Guide.
Q:
What happened to jboss-serialization.jar?
A:
As of JBoss Cache 2.0.0, the dependency on JBoss Serialization has been dropped since most of the benefits of JBoss Serialization are available in updated Java 5 VMs. Since JBoss Cache 2.0.0 is baselined on Java 5, there was no need to provide these benefits separately.
Q:
Does JBoss Cache support partitioning?
A:
Not right now. JBoss Cache does not support partitioning that a user can configure to have different set of data residing on different cache instances while still participating as a replication group.
Q:
Does JBoss Cache handle the concept of application classloading inside, say, a Java EE container?
A:
Application-specific classloading is used widely inside a Java EE container. For example, a web application may require a new classloader to scope a specific version of the user library. However, by default JBoss Cache is agnostic to the classloader. In general, this leads to two kinds of problems:
  • Object instance is stored in cache1 and replicated to cache2. As a result, the instance in cache2 is created by the system classloader. The replication may fail if the system classloader on cache2 does not have access to the required class. Even if replication does not fail, a user thread in cache2 may not be able to access the object if the user thread is expecting a type defined by the application classloader.
  • Object instance is created by thread 1 and will be accessed by thread 2 (with two different classloaders). JBoss Cache has no notion of the different classloaders involved. As a result, you will have a ClassCastException. This is a standard problem in passing an object from one application space to another; JBoss Cache just adds a level of indirection in passing the object.
To solve the first kind of issue JBoss Cache uses a CacheMarshaller. Basically, this allows application code to register a classloader with a portion of the cache tree for use in handling objects replicated to that portion. See the CacheMarshaller section of the JBoss Cache User Guide for more details.
To solve the second kind of issue, you can use the UseLazyDeserialization configuration option in JBoss Cache, which wraps your objects in a Marshalledvalue wrapper. The MarshalledValue serializes and deserializes your object on demand, ensuring the proper thread local context class loader is used each time.
Q:
Does JBoss Cache currently support pre-event and post-event notification?
A:
Yes. A boolean is passed in to each notification callback identifying whether the callback is before or after the event. See the org.jboss.cache.notifications.annotations.CacheListener annotation for details.
Q:
How do I implement a custom listener to listen to cache events?
A:
See the JBoss Cache User Guide on this subject.
Q:
Can I use the UseRegionBasedMarshalling attribute in JBoss Cache in order to get around ClassCastExceptions happening when accessing data in the cache that has just been redeployed?
A:
Yes, you can. Originally, cache Marshaling was designed as a workaround for those replicated caches that upon state transfer did not have access to the classloaders defining the objects in the cache.
On each deployment, JBoss creates a new classloader per the top level deployment artifact, for example an EAR. You also have to bear in mind that a class in an application server is defined not only by the class name but also its classloader. So, assuming that the cache is not deployed as part of your deployment, you could deploy an application and put instances of classes belonging to this deployment inside the cache. If you did a redeployment and try to do a get operation of the data previously put, this would result in a ClassCastException. This is because even though the class names are the same, the class definitions are not. The current classloader is different to the one when the classes were originally put.
By enabling Marshaling, you can control the life cycle of the data in the cache and if on undeployment, you deactivate the region and unregister the classloader that you'd have registered on deployment, you'd evict the data in the cache locally. That means that in the next deployment, the data will not be in the cache, therefore avoiding the problem. Obviously, using Marshaling to get around this problem is only recommended when you have some kind of persistence backing where the data survives, for example using CacheLoaders, or when JBoss Cache is used as a second level cache in a persistence framework.
To implement this feature, please follow the instructions indicated in the example located in the CacheMarshaller section of the Users' Guide. It's worth noting that instead of a ServletContextListener, you could add this code into an MBean that contained life cycle methods, such as start() and stop(). The key would be for this MBean to depend on the target cache, so that it can operate as long as the cache is up and running.

Chapter 3. Eviction Policies

Q: Does JBoss Cache support eviction policies?
Q: Does JBoss Cache's eviction policy operate in replication mode?
Q: Does JBoss Cache support Region?
Q: I have turned on the eviction policy. Why do I still get an Out of Memory (OOM) exception?
Q:
Does JBoss Cache support eviction policies?
A:
Yes. JBoss Cache currently supports multiple eviction policies such as LRU, MRU, and FIFO. Users can also plug in their own eviction policy algorithms. See the JBoss Cache User Guide for details.
Q:
Does JBoss Cache's eviction policy operate in replication mode?
A:
Yes and no.
The eviction policy only operates in local mode. That is, nodes are only evicted locally. This may cause the cache contents not to be synchronized temporarily. But when a user tries to obtain the cached contents of an evicted node and finds out that is null (e.g., get returns null), it should get it from the other data source and re-populate the data in the cache. During this moment, the node content will be propagated and the cache content will be in sync.
However, you still can run eviction policies with cache mode set to either REPL_SYNC or REPL_ASYNC. Depending on your use case, you can set multiple cache instances to have their own eviction policy (which are applied locally) or just have selected instances with eviction policies activated.
Also note that, with cache loader option, a locally evicted node can also be persisted to the back end store and a user can retrieve it from the store later on.
Q:
Does JBoss Cache support Region?
A:
Yes. JBoss Cache has the notion of region where a user can configure the eviction policy parameters (e.g., maxNodes or timeToIdleSeconds)
A region in JBoss Cache denotes a portion of tree hierarchy, e.g., a fully qualified name (org.jboss.cache.Fqn). For example, a user can define /org/jboss and /org/foocom as two separate regions. But note that you can configure the region programmatically now, i.e., everything has to be configured through the XML file.
Q:
I have turned on the eviction policy. Why do I still get an Out of Memory (OOM) exception?
A:
OOM can happen when the speed of cache access exceeds the speed of eviction policy handling timer. Eviction policy handler will wake up every wakeUpInterval milliseconds (or wakeUpIntervalSeconds seconds, prior to 3.x) to process the eviction event queue. So when the queue size is full, it will create a backlog and cause out-of-memory exceptions to happen unless the eviction timer catches up. To address this problem, in addition to increase the VM heap size, you can also reduce the wakeUpInterval so the timer thread processes the queue more frequently.

Chapter 4. Cache Loaders

Q: What is a cache loader?
Q: Is the FileCacheLoader recommended for production use?
Q: Can writing to cache loaders be asynchronous?
Q: Can I write my own cache loader?
Q: Does a cache loader have to use a persistent store?
Q: Can I use more than one cache loader?
Q: Can I migrate a JDBCacheLoader or FileCacheLoader based cache store containing data formatted with JBoss Cache 1.x.x to JBoss Cache 2.0 format?
Q: Is the TCPDelegatingCacheLoader resilient to TCPCacheServer restarts?
Q:
What is a cache loader?
A:
A cache loader is the connection of JBoss Cache to a (persistent) data store. The cache loader is called by JBoss Cache to fetch data from a store when that data is not in the cache, and when modifications are made to data in the cache the Cache Loader is called to store those modifications back to the store.
In conjunction with eviction policies, JBoss Cache with a cache loader allows a user to maintain a bounded cache for a large back end datastore. Frequently used data is fetched from the datastore into the cache, and the least used data is evicted, in order to provide fast access to frequently accessed data. This is all configured through XML, and the programmer does not have to take care of loading and eviction.
JBoss Cache currently ships with several cache loader implementations, including:
  • org.jboss.cache.loader.FileCacheLoader: this implementation uses the file system to store and retrieve data. JBoss Cache nodes are mapped to directories, subnodes to subdirectories, etc. Attributes of a node are mapped to a data file inside the directory.
  • org.jboss.cache.loader.jdbm.JdbmCacheLoader: this implementation is based on JDBM, an open source file-based transactional persistence engine.
  • org.jboss.cache.loader.bdbje.BdbjeCacheLoader: this implementation is based on Oracle's Berkeley DB Java Edition database, a fast and efficient transactional database. It uses a single file for the entire store. Note that if you use the Berkeley DB cache loader with JBoss Cache and wish to ship your product, you will have to acquire a commercial license from Oracle.
  • org.jboss.cache.loader.JDBCCacheLoader: this implementation uses the relational database as the persistent storage.
  • And more. See the chapter on cache loaders in the JBoss Cache User Guide for more details.
Q:
Is the FileCacheLoader recommended for production use?
A:
No, it is not. The FileCacheLoader has some severe limitations which restrict its use in a production environment, or if used in such an environment, it should be used with due care and sufficient understanding of these limitations.
  • Due to the way the FileCacheLoader represents a tree structure on disk (directories and files) traversal is inefficient for deep trees.
  • Usage on shared file systems like NFS, Windows shares, etc. should be avoided as these do not implement proper file locking and can cause data corruption.
  • Usage with an isolation level of NONE can cause corrupt writes as multiple threads attempt to write to the same file.
  • File systems are inherently not transactional, so when attempting to use your cache in a transactional context, failures when writing to the file (which happens during the commit phase) cannot be recovered.
As a rule of thumb, it is recommended that the FileCacheLoader not be used in a highly concurrent, transactional or stressful environment, and its use is restricted to testing.
Q:
Can writing to cache loaders be asynchronous?
A:
Yes. Set the async attribute to true. See the JBoss Cache Users' Guide for a more detailed discussion. By default though, all cache loader writes are synchronous and will block.
Q:
Can I write my own cache loader?
A:
Yes. A cache loader is a class implementing org.jboss.cache.loader.CacheLoader or extending org.jboss.cache.loader.AbstractCacheLoader. It is configured via the XML file (see JBoss Cache User Guide).
Q:
Does a cache loader have to use a persistent store?
A:
No. A cache loader could, for example, fetch (and possibly store) its data from a webdav-capable webserver. Another example is a caching proxy server, which fetches contents from the web. Note that an implementation of CacheLoader may not implement the 'store' functionality in this case, but just the 'load' functionality.
Q:
Can I use more than one cache loader?
A:
Yes. Within the CacheLoaderConfiguration XML element (see the JBoss Cache User Guide chapter on cache loaders) you can describe several cache loaders. The impact is that the cache will look at all of the cache loaders in the order they've been configured, until it finds a valid, non-null element of data. When performing writes, all cache loaders are written to (except if the ignoreModifications element has been set to true for a specific cache loader).
Q:
Can I migrate a JDBCacheLoader or FileCacheLoader based cache store containing data formatted with JBoss Cache 1.x.x to JBoss Cache 2.0 format?
A:
Yes. See the "Transforming Cache Loaders" section within the "Cache Loaders" section located in the JBoss Cache User Guide.
Q:
Is the TCPDelegatingCacheLoader resilient to TCPCacheServer restarts?
A:
As of JBoss Cache 2.1.0, the answer is yes. See the JBoss Cache User Guide for details on how to configure and tune your retries and wait period for reestablishing the TCP connection.
Prior to that, restarting the TCPCacheServer would also mean restarting your application that uses the cache.

Chapter 5. Troubleshooting

Q: I am having problems getting JBoss Cache to work, where can I get information on troubleshooting?
Q:
I am having problems getting JBoss Cache to work, where can I get information on troubleshooting?
A:
Troubleshooting section can be found in the following wiki link.

Appendix A. Revision History

Revision History
Revision 5.2.0-100.4002013-10-30Rüdiger Landmann
Rebuild with publican 4.0.0
Revision 5.2.0-100Wed 23 Jan 2013Russell Dickenson
Incorporated changes for JBoss Enterprise Application Platform 5.2.0 GA. For information about documentation changes to this guide, refer to Release Notes 5.2.0.
Revision 5.1.2-100Thu Dec 8 2011Jared Morgan
Incorporated changes for JBoss Enterprise Application Platform 5.1.2 GA. For information about documentation changes to this guide, refer to Release Notes 5.1.2.
Revision 5.1.1-100Mon Jul 18 2011Jared Morgan
Incorporated changes for JBoss Enterprise Application Platform 5.1.1 GA. For information about documentation changes to this guide, refer to Release Notes 5.1.1.
Revision 5.1.0-100Wed Sep 15 2010Laura Bailey
Changed version number in line with new versioning requirements.
Revised for JBoss Enterprise Application Platform 5.1.0.GA.

Legal Notice

Copyright © 2012 Red Hat, Inc.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.