| Last Update: | Aug 04, 2003 |
| Status: | Production |
| Version: | Any PDK Release |
Oracle9iAS Portal provides functionality for caching of PL/SQL portlets. This functionality permits PL/SQL portlets to have their Web content cached by the middle tier. Subsequent requests for the content may be retrieved from the cache, with or without validation from the database, decreasing the database workload.
Oracle9iAS provides two ways to enable caching in your PL/SQL portlets. You can either choose to use Validation based caching or Expiry based caching. The first method compares a key value to check whether the cache is still valid. If the key value doesn't change, it uses the cached content otherwise it makes a round trip to the Portal node to fetch the portlet content. The second method uses a given expiration period to use the cache for rendering the portlet.
This article describes how Expiry based caching can be implemented in your portlets. It provides a guideline for adding caching to your portlet functionality.Before you can start using Caching, it must be enabled in your Portal installation. The section on 'How to Enable Caching' in the Primer on Caching document explains how this setup can be done.
The general model for using Caching can be described as follows:
CREATE OR REPLACE
package body EXPIRYCACHE_PORTLET
is
-- Caching Constants --
CACHE_LEVEL_SYSTEM constant varchar2(10) := 'SYSTEM';
CACHE_LEVEL_USER constant varchar2(10) := 'USER';
function get_portlet_info
(
p_provider_id in integer
,p_language in varchar2
)
return wwpro_api_provider.portlet_record
is
l_portlet wwpro_api_provider.portlet_record;
begin
l_portlet.id := cache_provider.PORTLET_EXPIRYCACHE;
l_portlet.provider_id := p_provider_id;l_portlet.title := 'Expiry Based Caching';
l_portlet.name := 'Expiry_Cache';
l_portlet_descriptin := 'This portlet illustrates expiry based caching';
...
end EXPIRYCACHE_PORTLET;
/
CREATE OR REPLACE
package body EXPIRYCACHE_PORTLET
is
...
procedure show
(
p_portlet_record in out wwpro_api_provider.portlet_runtime_record
)
is
l_portlet wwpro_api_provider.portlet_record;begin
-- Perform the Security Check
if not is_runnable(p_provider_id, null)
then
-- Set it to null so that cache does not get used even if exists
p_portlet_record.caching_level := null;
p_portlet_record.caching_period := null;
raise wwpro_api_provider.PROVIDER_SECURITY_EXCEPTION;
end if;
-- Set the Caching Period to one minutel_cache_period := 1;
...
end show;
end EXPIRYCACHE_PORTLET;
/
CREATE OR REPLACE
package body EXPIRYCACHE_PORTLET
is
...
procedure show
(
p_portlet_record in out wwpro_api_provider.portlet_runtime_record
)
...
-- Set the Caching Period to one minute
l_cache_period := 1;
-- SYSTEM CACHE is nothing but an empty portlet. The user has done
-- nothing yet!
if p_portlet_record.caching_level = CACHE_LEVEL_SYSTEM then
-- Cache does not exist for the user, create it
p_portlet_record.caching_level := CACHE_LEVEL_USER;
p_portlet_record.caching_period := l_cache_period;
elsif p_portlet_record.caching_level = CACHE_LEVEL_USER then
-- Cache exists for the user, overwrite it
p_portlet_record.caching_period := l_cache_period;
elsif p_portlet_record.caching_level is null then
if p_portlet_record.caching_period is not null then
-- Cache does not exist for the user, create it
p_portlet_record.caching_level := CACHE_LEVEL_USER;
p_portlet_record.caching_period := l_cache_period;
else
-- Define a system cache. This can happen only once!
-- the first time the portlet is rendered.
p_portlet_record.caching_level := CACHE_LEVEL_SYSTEM;
p_portlet_record.caching_period := l_cache_period;
end if;
else -- p_portlet_record.caching_level value is messed up!
p_portlet_record.caching_level := CACHE_LEVEL_SYSTEM;
p_portlet_record.caching_period := l_cache_period;
end if;
if (p_portlet_record.exec_mode = wwpro_api_provider.MODE_SHOW) then...
end show;
...
end EXPIRYCACHE_PORTLET;
/
| Revision History: |
|
| Oracle Corporation World Headquarters 500 Oracle Parkway Redwood Shores, CA 94065, USA http://www.oracle.com/ |
Worldwide Inquiries: 1-800-ORACLE1 Fax 650.506.7200 |
Copyright and Corporate Info |