File: database.mli

package info (click to toggle)
netclient 0.91-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,096 kB
  • ctags: 1,539
  • sloc: ml: 8,808; sh: 527; makefile: 203
file content (48 lines) | stat: -rw-r--r-- 1,806 bytes parent folder | download | duplicates (12)
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
type t

val create : unit -> t

val restore : string -> t
  (* Restores the database from a file *)

val save : t -> string -> unit
  (* Saves the database into a file *)

val lookup : t -> string -> (int * float * float * string)
  (* lookup db url:
   * Finds the entry for 'url' in 'db' or raises Not_found.
   * It returns a tuple (code, time, mimetype):
   * - code: the HTTP code returned.
   *         0 means: Not yet requested.
   * - time_ok: when the last successful access happened
   *         0.0 means: Never
   * - time_access: when the last access happened
   *         0.0 means: Never
   * - mimetype: the MIME type of the entry
   *         "" means: unknown
   *)

val add : t -> string -> unit
  (* add db url: Adds an entry *)

val update : t -> string -> int -> float -> float -> string -> unit
  (* update db url code time_ok time_access mimetype:
   * Changes the entry for 'url' in 'db'.
   * Raises Not_found if an entry for 'url' does not exist.
   *)

val iter : t -> float -> float -> 
              (string * int * float * float * string) Stream.t 
  (* iter db f age interval:
   * Iterates over all entries of 'db', and includes all entries into
   * the resulting stream that
   * do not have a successful HTTP code, or are older than 'age' seconds;
   * but the access time must not be older than 'interval'.
   * The stream elements are: url,code,time_ok,time_access,mimetype.
   * While the stream is being consumed, it is allowed to modify
   * the contents of 'db'; the changed or added entries
   * will be reached if they match the criterion.
   * The iteration terminates normally if no entry currently matches the
   * criterion. [The returned number is the suggested period of time to wait
   * until the next invocation of 'iter' makes sense. ... TODO ]
   *)