summaryrefslogtreecommitdiff
path: root/fml/doc/en/tutorial/internals/db_modules.sgml
blob: 55c855a73fa79e96cf563c068d5eda0c65429e11 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!--
   $FML: db_modules.sgml,v 1.1 2005/08/03 13:22:06 fukachan Exp $
-->

<!--
    XXX-TODO: database
-->


<chapter id="db.module">
	<title>
	Database Related Modules
	</title>


<sect1 id="db.module.ovewview">
	<title>
	Overview
	</title>

<para>
ML driver needs to hold some data on mail.  Some data exixsts
persistently but some data with expiration (data is discarded after
some interval).
</para>

<para>
An example of permisistent data is thread database.
The latter case, an exapmle of non persistent data, is message-id cache.
The thread database also has message-id cache in it, which is a
sub-set of all message-id set of incoming messages. We handle these
two data separately.
</para>

<para>
We should handle these data in integrated way.
<screen>
module A ---| A  |--- persistent database
module B ---| da |
module C ---| pt |
modlue D ---| er |--- cache with expiration
</screen>
An example of this persistent DB, thread DB, is 
<link linkend="threadtrack.db">
Mail::Message::DB
</link>
class.  Examples of cache database are Tie::JournaledDir and
FML::Cache::Ring classes.
</para>

<para>
It is better to use RDBMS for important persistent data such as
address list. This chapter describes persistent data handling only for
&fml8; internal use.
</para>

</sect1>


<sect1 id="db.module.persistent">
	<title>
	Persistent Data Use
	</title>

<para>
Handling of persistent data is important.
We should consider use of 
<link linkend="dbms">
DBMS
</link>
	<footnote>
	<para>
	DBMS = DataBase Management System
	</para>
	</footnote>
for important data.
</para>

<para>
This chapter describes only &fml8; internal use.
</para>

<para>
&fml8; provides two type of cache databases.
The type is time saving or space saving.
</para>

</sect1>


<sect1 id="db.module.Tie.JournaledFile">
	<title>
	Tie::JournaledFile Class
	</title>

<para>
This class appends data into a file.
	<ulink url="../../en/modules/Tie/JournaledFile.txt">
	Tie::JournaledFile
	</ulink>
class provides this function.
</para>

<para>
This class is append only. It is similar to LFS (Log Structured File
System).
</para>

<para>
Operation to extract a value is to get the latest (last appended) value.
That is, the last match.
</para>

<para>
In other words, data cache logs all data to enable back track.
</para>

<para>
We cannot restrict the maximum size of this cache.
This class holds data within some period without size limitation.
We control cache expiration by time.
</para>


<para>
To get the following structure as a result, 
you can use get_all_values_as_hash_ref() method.
<screen>
key => [
	log1	(line A of file 1),
	log2	(line B of file 2),
	log2	(line C of file 3),
]
</screen>
</para>


<warning>
<para>
Search algorithm is either of first match or last match. The last
match by default since the last appended data is latest.
</para>
</warning>

</sect1>


<sect1 id="db.module.FML.Cache.Ring">
	<title>
	FML::Cache::Ring Class
	</title>

<para>
	<ulink url="../../en/modules/File/CacheDir.txt">
	FML::Cache::Ring
	</ulink>
holds data with size limit but without time limitation.
</para>


<para>
It is suitable for debug since the debug data is expected not to eat
disk.
</para>


<para>
This class holds data in files in a directory such as
$ml_home_dir/var/db/.
For example, files named as db/1 .. db/100 are created.
These files are used repeatedly.
</para>


<warning>
<para>
RingBuffer class is integrated into FML::Cache::Ring class.
FML::Cache::Ring is derived from File::CacheDir class.
</para>
</warning>

</sect1>


</chapter>