forked from ezSQL/ezsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk_cache_example.php
More file actions
executable file
·56 lines (39 loc) · 1.43 KB
/
Copy pathdisk_cache_example.php
File metadata and controls
executable file
·56 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// Standard ezSQL Libs
include_once "../shared/ez_sql_core.php";
// Include ezSQL database specific component
include_once "ez_sql_oracle8_9.php";
// Initialise database object and establish a connection
// at the same time - db_user / db_password / db_name
$db = new ezSQL_oracle8_9('user','password','oracle.instance');
// Cache expiry
$db->cache_timeout = 24; // Note: this is hours
// Specify a cache dir. Path is taken from calling script
$db->cache_dir = 'ezsql_cache';
// (1. You must create this dir. first!)
// (2. Might need to do chmod 775)
// Global override setting to turn disc caching off
// (but not on)
$db->use_disk_cache = true;
// By wrapping up queries you can ensure that the default
// is NOT to cache unless specified
$db->cache_queries = true;
// At last.. a query!
$db->get_var("SELECT " . $db->sysdate() . " FROM DUAL");
$db->debug();
// Now get it from the cache
$db->get_var("SELECT " . $db->sysdate() . " FROM DUAL");
$db->debug();
// This ensures only the above querys are cached
$db->cache_queries = false;
// This query is NOT cached
$db->get_var("SELECT " . $db->sysdate() . " FROM DUAL");
$db->debug();
/*
Of course, if you want to cache EVERYTHING just do..
$db = new ezSQL_oracle8_9('user','password','oracle.instance');
$db->use_disk_cache = true;
$db->cache_queries = true;
$db->cache_timeout = 24;
*/
?>