本文討論如果1個Cache Table設定了Aging策略,那末Aging致使的緩存中數據的刪除是不是會影響到Oracle數據庫?
如果是只讀緩存組,固然是不會影響到Oracle的。如果是AWT緩存組,答案也是不會影響,即Aging致使的數據刪除不會傳播到Oracle,下面通過實驗驗證1下。
之前的建立緩存組的準備工作此處略過。
在Oracle中建立源表(schema 用戶 - tthr):
create table t1(id int not null, t timestamp not null, primary key(id));
啟動cache agent。
建立AWT緩存組(cache管理用戶 - cacheadm),定義Aging策略為基于TimeStamp,生命周期為10秒,檢查周期為5秒
CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP "AGEAWT"
FROM
"TTHR"."T1" (
"ID" NUMBER(38) NOT NULL,
"T" TIMESTAMP(6) NOT NULL,
PRIMARY KEY("ID")
)
AGING USE T LIFETIME 10 seconds CYCLE 5 seconds ON
start rep agent
在TimesTen中插入數據
$ ttisql "dsn=cachedb1_1122;uid=tthr;pwd=timesten"
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "dsn=cachedb1_1122;uid=tthr;pwd=timesten";
Connection successful: DSN=cachedb1_1122;UID=tthr;DataStore=/home/oracle/TimesTen/tt1122/info/DemoDataStore/cachedb1_1122;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/home/oracle/TimesTen/tt1122/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;OracleNetServiceName=ttorcl;
(Default setting AutoCommit=1)
Command> select * from t1;
0 rows found.
Command> insert into t1 values(1, sysdate);
1 row inserted.
Command> select * from t1;
< 1, 2016-05-30 01:12:49.000000 >
1 row found.
Command> select * from t1; <- aging生效了
0 rows found.
Command> insert into t1 values(2, sysdate);
1 row inserted.
Command> select * from t1;
< 2, 2016-05-30 01:13:50.000000 >
1 row found.
Command> select * from t1; <- aging生效了
0 rows found.
Command>
在Oracle中視察數據變化, 可以看到數據不斷增加,沒有由于Aging而被刪除
$ sqlplus tthr/oracle@ttorcl
SQL*Plus: Release 11.2.0.2.0 Production on Mon May 30 01:12:27 2016
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from t1;
no rows selected
SQL> select * from t1;
no rows selected
SQL> /
ID
----------
T
---------------------------------------------------------------------------
1
30-MAY⑴6 01.12.49.000000 AM
SQL> /
ID
----------
T
---------------------------------------------------------------------------
1
30-MAY⑴6 01.12.49.000000 AM
2
30-MAY⑴6 01.13.50.000000 AM