1. 先在sys.odbc.ini配置一个DSN
#######################################################
[ttdemo]
Driver=/opt/TimesTen/tt70/lib/libtten.so
DataStore=/var/TimesTen/tmp/ttdemo
DatabaseCharacterSet=WE8ISO8859P1
TempSize=20
PermSize=20
Authenticate=0
UID=test
OracleID=shacola
OraclePwd=123456
Logging=1
Isolation=1
PassThrough=0
LockLevel=0
TypeMode=0
#######################################################
2 创建Oracle测试表并准备数据
sqlplus test/123456
CREATE TABLE readtab (a NUMBER NOT NULL PRIMARY KEY, b VARCHAR2(31));
INSERT INTO readtab VALUES (1, 'hello');
INSERT INTO readtab VALUES (2, 'world');
COMMIT;
3. 创建 cache group
ttisql ttdemo
call ttCacheUidPwdSet('test','123456');
call ttCacheStart;
CREATE READONLY CACHE GROUP readcache
AUTOREFRESH INTERVAL 5 SECONDS
FROM readtab
(a NUMBER NOT NULL PRIMARY KEY, b VARCHAR2(31));
4. 装载数据
LOAD CACHE GROUP readcache COMMIT EVERY 256 ROWS;
SELECT * FROM readtab;
5: 在源表里插入新的数据
sqlplus test/123456
INSERT INTO readtab VALUES (3, 'Hello');
INSERT INTO readtab VALUES (4, 'Again');
COMMIT;
6. 检查cache是否刷新
需要等待AUTOREFRESH INTERVAL 指定的时间,本例中是5秒
7. 测试完毕, 打扫一下
DROP CACHE GROUP readcache;
call ttCacheStop;