Atte Kojo avatar Atte Kojo committed 03e477e

Renamed Cnt -> Continuum for better readability.

Comments (0)

Files changed (1)

 (* The data structure holding the key-server mapping, i.e. the continuum. Uses
  * consistent hashing to map keys to servers to minimize the effect of
  * adding/removing servers. *)
-module Cnt = struct
+module Continuum = struct
     module ConnKey = struct
         type t = string * int
         let compare = Pervasives.compare
         output: out_channel;
     }
 
-    type 'a t = connection Cnt.t
+    type 'a t = connection Continuum.t
 
     let nservers = 200
 
         | None -> []
 
     let store cmd cache expires key data =
-        let conn = Cnt.connection_for key cache in
+        let conn = Continuum.connection_for key cache in
         let datastr = Value.to_string data in
         let len = String.length datastr in
         write_line conn (sprintf "%s %s 0 %d %d" cmd key expires len);
         | _ -> failwith cmd
 
     let arith cmd cache key value =
-        let conn = Cnt.connection_for key cache in
+        let conn = Continuum.connection_for key cache in
         write_line conn (sprintf "%s %s %d" cmd key value);
         match List.hd (read_line conn) with
         | "NOT_FOUND" -> None
 
     (* External interface *)
 
-    let create () = Cnt.empty nservers
+    let create () = Continuum.empty nservers
 
     let connect cache (hostname, port) =
         let h_addr = (gethostbyname hostname).h_addr_list.(0) in
         let (input, output) = open_connection (ADDR_INET(h_addr, port)) in
         let conn = { input = input; output = output } in
         let () = Gc.finalise connection_finalizer conn in
-        Cnt.add (hostname, port) conn cache
+        Continuum.add (hostname, port) conn cache
 
     let disconnect cache (hostname, port) =
         (* No need to disconnect here since the finalizer will do it. *)
-        Cnt.remove (hostname, port) cache
+        Continuum.remove (hostname, port) cache
 
     let get cache key =
-        let conn = Cnt.connection_for key cache in
+        let conn = Continuum.connection_for key cache in
         write_line conn ("get " ^ key);
         match (read_list read_value conn) with
         | [] -> None
         store "replace" cache expires key data
 
     let delete cache ?(wait_time = 0) key =
-        let conn = Cnt.connection_for key cache in
+        let conn = Continuum.connection_for key cache in
         write_line conn (sprintf "delete %s %d" key wait_time);
         match read_line conn with
         | ["DELETED"] -> true
     let decr cache key value = arith "decr" cache key value
 
     let stats cache host =
-        let conn = Cnt.find host cache in
+        let conn = Continuum.find host cache in
         write_line conn "stats";
         read_list read_stat conn
 end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.