Source file redis_sync.ml
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
module IO = struct
type 'a t = 'a
type fd = Unix.file_descr
type nonrec in_channel = in_channel
type nonrec out_channel = out_channel
type 'a stream = 'a Stream.t
type stream_count = int
let (>>=) a f = f a
let (>|=) a f = f a
let catch f exn_handler = try f () with e -> exn_handler e
let try_bind f bind_handler exn_handler = try f () >>= bind_handler with e -> exn_handler e
let ignore_result = ignore
let return a = a
let fail e = raise e
let run a = a
let atomic f ch = f ch
let connect host port =
let port = string_of_int port in
let addr_info =
let open Unix in
match getaddrinfo host port [AI_FAMILY PF_INET] with
| ai::_ -> ai
| [] ->
match getaddrinfo host port [AI_FAMILY PF_INET6] with
| ai::_ -> ai
| [] -> failwith "Could not resolve redis host!"
in
let fd = Unix.socket addr_info.Unix.ai_family Unix.SOCK_STREAM 0 in
try
Unix.connect fd addr_info.Unix.ai_addr; fd
with
exn -> Unix.close fd; raise exn
let close = Unix.close
let sleep a = ignore (Unix.select [] [] [] a)
let in_channel_of_descr = Unix.in_channel_of_descr
let out_channel_of_descr = Unix.out_channel_of_descr
let input_char = input_char
let really_input = really_input
let output_string = output_string
let flush = flush
let iter = List.iter
let iter_serial = List.iter
let map = List.map
let map_serial = List.map
let fold_left = List.fold_left
let stream_from = Stream.from
let stream_next = Stream.next
end
module Client = Redis.Client.Make(IO)
module Cache = Redis.Cache.Make(IO)(Client)
module Mutex = Redis.Mutex.Make(IO)(Client)
module ClusterClient = Redis.Client.MakeCluster(IO)
module ClusterCache = Redis.Cache.Make(IO)(ClusterClient)
module ClusterMutex = Redis.Mutex.Make(IO)(ClusterClient)