-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlcache.install
More file actions
120 lines (115 loc) · 3.06 KB
/
lcache.install
File metadata and controls
120 lines (115 loc) · 3.06 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/**
* Implements hook_requirements().
*/
function lcache_requirements($phase) {
// @TODO: Version check for APCu.
// @TODO: Check for a sane apcu_sma_info() configuration here.
}
/**
* Implements hook_schema().
*/
function lcache_schema() {
$schema['lcache_events'] = array(
'description' => 'Stores a stream of cache changes for coherency management.',
'fields' => array(
'event_id' => array(
'description' => 'Primary Key: Event ID.',
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'pool' => array(
'description' => 'PHP process pool that wrote the change.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'binary' => TRUE,
'default' => '',
),
'address' => array(
'description' => 'Cache entry address (bin and key).',
'type' => 'varchar_ascii',
'length' => 512,
'not null' => FALSE,
'binary' => TRUE,
'default' => NULL,
),
'value' => array(
'description' => 'Cache entry value.',
'type' => 'blob',
'not null' => FALSE,
'binary' => TRUE,
'size' => 'big',
),
'expiration' => array(
'description' => 'A Unix timestamp indicating when the cache entry should expire, or NULL for never.',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
),
'created' => array(
'description' => 'A Unix timestamp indicating when the cache entry was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'expiration' => array('expiration'),
'lookup_miss' => array('address', 'event_id'),
),
'primary key' => array('event_id'),
);
$schema['lcache_tags'] = array(
'description' => 'Stores mappings from tags to cache items.',
'fields' => array(
'tag' => array(
'description' => 'Cache tag.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
'binary' => TRUE,
'default' => NULL,
),
'event_id' => array(
'description' => 'The event_id associated with the cache entry.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'rewritten_entry' => array('event_id'),
),
'primary key' => array('tag', 'event_id'),
'foreign keys' => array(
'lcache_events_event_id' => array(
'table' => 'lcache_events',
'columns' => array('event_id' => 'event_id'),
),
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function lcache_install() {
db_query('
ALTER TABLE {lcache_tags}
ADD CONSTRAINT {lcache_tags_event_id}
FOREIGN KEY (event_id) REFERENCES {lcache_events} (event_id)
ON DELETE CASCADE
');
}
/**
* Implements hook_uninstall().
*/
function lcache_uninstall() {
db_query('
ALTER TABLE {lcache_tags}
DROP FOREIGN KEY {lcache_tags_event_id}
');
}