JNDI cache behavior

A cache is associated with an initial context when a javax.naming.InitialContext object is instantiated with the java.naming.factory.initial property set to com.ibm.websphere.naming.WsnInitialContextFactory.

WsnInitialContextFactory searches the environment properties for a cache name, defaulting to the provider URL. If no provider URL is defined, the cache name iiop:/// is used. All instances of InitialContext that use a cache of a given name share the same cache instance.

After an association between an InitialContext instance and cache is established, the association does not change. A javax.naming.Context object returned from a lookup operation will inherit the cache association of the Context object on which the lookup was performed. Changing cache property values with the Context.addToEnvironment() or Context.removeFromEnvironment() method does not affect cache behavior. Properties affecting a given cache instance, however, may be changed with each InitialContext instantiation.

A cache is restricted to a process and does not persist beyond the life of the process. A cached object is returned from lookup operations until either the maximum cache life for the cache is reached, or the maximum entry life for the object's cache entry is reached.

After the object's cache reaches its maximum life or the object reaches its maximum entry life, a lookup on the object causes the cache entry for the object to be refreshed. If a bind or rebind operation is performed on an object, the change is not reflected in any caches other than the one associated with the context from which the bind or rebind operation was issued. This "stale data" scenario is most likely to happen when multiple processes are involved because different processes do not share the same cache, and Context objects in all threads in a process typically share the same cache instance for a given name service provider.

Cached objects are typically relatively static entities, and objects becoming stale should not be a problem. However, you can set timeout values on cache entries or on a cache to periodically refresh cache contents.