Back to JOC 10.1.2 Tutorial Index

Getting Started

Using the Java Object Cache in your Java program is quite straightforward. To access the Cache Service, you will mainly use the CacheAccess class. The following short lessons will guide you through how to use some basic functions of the Cache Service in your Java programs.

The package name of the Java Object Cache is oracle.ias.cache. It is distributed as cache.jar. Follow this link, if you have not downloaded it yet.

To use the Cache Service, you need to import:

import oracle.ias.cache.*;
To access the Cache Service, you need to obtain an instance of the CacheAccess object:
  CacheAccess cacc = CacheAccess.getAccess();
getAccess returns an instance of a CacheAccess object which allows access to a region of the cache. getAccess without an argument will give access to the default cache region. See the chapter on Defining Your Environment for more information on defining your own regions.

To store an object directly into the cache you would call the put method of CacheAccess supplying an unique name for the object in the cache. For example, if you want to put the string "Some contents in the cache." into the cache, you would do:

  cacc.put("object_x", "Some contents in the cache.");
To get the object back from the cache, you would call the get method. For example, if you want to get "object_x" back, you would do:
  String str = (String) cacc.get("object_x");
Once you are done accessing the cache, you need to call close to release the CacheAccess object.
  cacc.close();
Back to JOC 10.1.2 Tutorial Index
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy