Oracle9iAS Portal Developer Kit
Caching Examples

The PL/SQL caching examples provide a detailed template for creating your own cached portlets. The code is well commented.

This document explains:

- How the caching examples are packaged and how to install them

- The two portlets included in the caching example:

  - Validate based Caching portlet
  - Expiry based Caching portlet

### CONTENTS

This section describes the files included in the caching example. There are package specifications (*.pks), package bodies (*.pkb), and a bare-bones installation script.

Files

- expirycache_portlet.pks: Contains detailed comments and headers for the Expiry based Caching Portlet.

- expirycache_portlet.pkb: Logic behind Expiry based Caching Portlet.

- validcache_portlet.pks: Contains detailed comments and headers for the Validation based Caching Portlet.

- validcache_portlet.pks: Logic behind Validation based Caching Portlet.

- cache_provider.pks: Contains detailed comments and headers for the Cache Provider.

- cache_provider.pkb: Logic behind Cache Provider.

- cache_install.sql: Script that compiles the portlet and provider packages. Called internally by install.sql.

- cache_register.sql : Called internally by install.sql for registering the cache provider. This needs to be run in the Portal schema only.

- install.sql: Main installation script that installs this sample. Prompts the user for 4 parameters - Portal schema, Portal password, Provider schema and Provider schema password.

Documentation

- installing.cache.html: This document.

###
SETUP

To give you a good understanding of what goes on behind the scenes, these instructions describe how to install the caching examples manually.

Installing the Packages

1. Find provsyns.sql and change to that directory (e.g. c:\portal30\webdb30\admin\plsql\wwc). Later, you will run this script to grant permission to call Oracle9iAS Portal APIs.
2. Create the schema where you will install the example:
   - Login to sqlplus (e.g. sqlplus sys/change_on_install)
   - Create a new schema (e.g. create user starter identified by starter;)
   - Give it permissions (e.g. grant connect, resource to starter;)
3. Grant your schema permission to call Oracle9iAS Portal APIs:
   - Login as the schema where your portal is installed (e.g. connect portal30/portal30;)
   - Run provsyns.sql as the schema where your portal is installed (e.g. @provsyns.sql starter;)
   - Exit sqlplus
4. Install the cache example:
   - Change to the directory where you unzipped this example
   - Login to sqlplus as your schema (e.g. sqlplus starter/starter)
   - Run install.sql (e.g. @install.sql)
   - Provide the inputs to this script when it asks for the following:
     - Portal schema username - Schema of Oracle Portal
     - Portal schema password
     - Provider schema username - Schema where you want to install this Provider
     - Provider schema password

The install.sql script runs each of the PL/SQL package scripts in turn. After completing these steps, all the logic needed to run your sample database provider and portlets resides in the database.

Registering Your Provider

The install script automatically registers your Provider for you. At the end of installation it prints out the Provider Registration information. Please verify that the Provider was registered successfully.

In order for Oracle9iAS Portal to display the Cache Provider (and for your users to see your portlets), you need to register this new provider.

1. Login to Oracle9iAS Portal as a portal administrator.

2. Click the Administer tab.

3. Under the Administer tab, click on Display Portlet Repository within the portlet called Provider.

4. Scroll down to verify that the Cache Provider is listed with the Validation based Caching Portlet and the Expiry based Caching portlet.

You are now all set to add this portlet to your own pages.

###
PORTLETS

The portlets in the Cache Provider are meant to serve as a guide for enabling caching in your portlets. They have been refined to reflect the best practices in PL/SQL portlet development.

Validation based Caching Portlet

This portlet illustrates how Validation based Caching can be used in your portlets. It displays the current time in HH:MI:SS format. You will find that the if you reload within the 10 seconds where the first digit of the seconds field has not yet changed, the portlet still displays the old time. Only if you refresh the page after those 10 seconds, the time displayed changes.

Expiry based Caching Portlet

This portlet illustrates how Expiry based Caching can be used in your portlets. It displays the current time in HH:MI:SS format. The caching period for this example is set to one minute. You will find that the if you reload within the one minute, the portlet still displays the old time. Only if you refresh the page after one minute, the time displayed is changed.

Revision history:

- January, 25 2001. Version 1.0.