Java objects and the command cache
DynaCache provides support for caching the returned results from Java™ object calls. DynaCache provides a very straightforward mechanism that allows you to cache the results from these Java command objects; it is called command caching.
Commands written to the WebSphere® command architecture access databases, file systems, and connectors to perform business logic, and often run remotely on another server. Significant performance gains can be achieved by caching command results and avoiding their repeated invocation.
To take advantage of command caching, applications must be written to the WebSphere command framework API. This API is based on a common programming model, and uses a series of getters(), setters() and execute() methods to retrieve its results. To use a command, the client creates an instance of the command and calls the execute() method for the command. Depending on the command, calling other methods could be necessary. The specifics will vary with the application.
With Command cache, the data is cached before it is transformed into HTML. In order to take advantage of command caching, you must make simple code changes to your Java objects so that DynaCache can call them to retrieve the data. Command objects inherit from com.ibm.websphere.command.cachableCommandImpl and must provide certain methods to function properly.
- Set
- Initialize the input properties of the command object.
- Execute
- Perform the specific business logic for which the command was written.
- Get
- Retrieve the output properties that are set by the command execution.
- New
- The command has been created but the input properties have not been set.
- Initialized
- The input properties have been set.
- Executed
- The execute method has been called and the output properties have been set and can be retrieved.
Executed command objects can be stored in the cache so that subsequent instances of that command object's execute method can be served by copying output properties of the cached command to the current command for retrieval by its get methods. DynaCache supports caching of command objects for later reuse by servlets, JSPs, EJBs, or other business logic programming.
Figure 1 shows the logic of a simple stock quote function similar to the Trade application.
