Putting Your Web Cache To Work: Cache Invalidation using PL/SQL

[复制链接]
查看11 | 回复0 | 2015-3-27 23:10:30 | 显示全部楼层 |阅读模式
John Garmany

The Oracle Web Cache is a powerful tool and one that I see few organizations taking advantage of it ability to cache dynamic documents.
A dynamic document or object is one created from data and is valid only as long as the data does not change.
It's the "does not change" part that makes caching dynamic objects difficult.It of course takes planningin both your application development and database model.
While you still have to determine when an object is no longer valid, Oracle provides some simple tools to perform the actual cache invalidation.
The Web cache listens on an invalidation port (mine installed on 4002) for a simple HTTP POST message.The message can come from a terminal, the application, or the database.
In PL/SQL the WXVUTIL package contains the procedures to send an invalidation message to the web cache.
First, the package must be loaded in the database.It is provides in the webcache/toolkit directory.
/webcache/toolkit/wxvutil.sql.

[oracle@appsvr toolkit]$ pwd
/opt/oracle/portal904/webcache/toolkit
[oracle@appsvr toolkit]$ ls -l
total 104
-rw-r--r--1 oracle oinstall672 Jul 112003 invalidation.dtd
-rw-r--r--1 oracle oinstall65389 Nov 122003 jawc.jar
-rw-r--r--1 oracle oinstall 70 Jul 112003 README.toolkit.txt
-rw-r--r--1 oracle oinstall 4348 Jul 112003 WCSinvalidation.dtd
-rw-r--r--1 oracle oinstall 6083 Jul 112003 wxvappl.sql
-rw-r--r--1 oracle oinstall10757 Jul 112003 wxvutil.sql
复制代码
Notice this is the application server (or web cache if on a separate server) ORACLE_HOME, not the database ORACLE HOME.
After the scripts are run you can create triggers on the underlying tables of the dynamic objects.When the database executes a DML operation on the table (INSERT, UPDATE or DELETE), the trigger invalidates the cached objects based on the table data.

CREATE OR REPLACE TRIGGER PRODUCT_INVALID_TRIG
AFTER DELETE OR INSERT OR UPDATE on PRODUCT FOR EACH ROW
BEGIN
wxvutil.invalidate_reset;
wxvutil.invalidate_uri('/MainApp/prod_list.jsp', 0,

null);
wxvutil.invalidate_exec('web.appsvr.com', 4002,

'oracie123');
END;
/
复制代码
You can invalidate a single object (as in the example above) or multiple objects.

wxvutil.invalidate_uri('/MainApp/prod_list.*', 0, null);
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行