Tutorial: Building cache identifiers
When the dynamic cache service places an object in the cache, it labels it with a unique identifying string known as a cache ID. The cache Id constructed according to <cache-id> rules specified in the <cache-entry> elements. The <cache-id> rules define how to construct cache-ids from information associated with an application server request.
Learning objectives
The <cache-id> is formed from a list of <components>. There are several different types of components that are available to build these cache-ids. This tutorial will outline several of them.
Time required
Expect this tutorial to take about 30 minutes to complete.
Audience
This tutorial is intended for WebSphere Commerce Administrators who will be responsible for building cache identifiers.
Prerequisites
Publish the consumer direct sample store.
Create a cachespec.xml file that caches the TopCategoriesDisplay page and the eMarketingSpot fragment of the consumer direct sample store.
Expected results
In this tutorial, you learned about the different methods for building cache-entries:
- WebSphere Commerce session attributes
- WebSphere Application Server session attributes
- Cookies
- CommandContext method calls
Lessons in this tutorial
- Add WebSphere Commerce DC_RequestAttributes
A servlet filter known as the cache filter enables the dynamic cache to use session information to construct the cache ID. The cache filter is designed to set up request attributes from the session data, MemberGroupsCacheCmd, and store relationship information. Dynamic cache can use the request attributes as component elements.
- Accept cache identifiers using method calls into the WebSphere Application
Cache-ids are composed from values that are in the WebSphere Application Server session.To access these values, specify a component type of session and use the value that is the name of the object in the session.
- Accept cache identifiers using cookies
The use of cookies does limit this component to Web-specific scenarios. You cannot use this component with other protocols, such as webservices.
- Accept cache identifiers using method calls into the CommandContext
It is possible to access parameters available in the CommandContext. Specifically, you can invoke methods on the CommandContext object so that certain values are accessed that would not be available.