diff --git a/.gitignore b/.gitignore index 2aa0c9b..7f0c67b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /*.byte /*.native /*.docdir +/.gh-pages diff --git a/Makefile b/Makefile index 3639f14..2a1c5c6 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ -# OASIS_START -# DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954) - SETUP = ocaml setup.ml +DOCDIR = .gh-pages +DOC_SYNC = $(DOCDIR)/redis.docdir +DOC_LWT = $(DOCDIR)/redis_lwt.docdir + build: setup.data $(SETUP) -build $(BUILDFLAGS) @@ -36,6 +37,20 @@ setup.data: configure: $(SETUP) -configure $(CONFIGUREFLAGS) -.PHONY: build doc test all install uninstall reinstall clean distclean configure +gh-pages: doc + git clone `git config --get remote.origin.url` .gh-pages --reference . + git -C .gh-pages checkout --orphan gh-pages + git -C .gh-pages reset + git -C .gh-pages clean -dxf + cp docs/index.html $(DOCDIR)/index.html + cp docs/style.css $(DOCDIR)/style.css + cp -r _build/src/redis.docdir $(DOC_SYNC) + cp -r _build/src/redis_lwt.docdir $(DOC_LWT) + cp docs/style.css $(DOC_SYNC)/style.css + cp docs/style.css $(DOC_LWT)/style.css + git -C .gh-pages add . + git -C .gh-pages commit -m "Update Pages" + git -C .gh-pages push origin gh-pages -f + rm -rf .gh-pages -# OASIS_STOP +.PHONY: build doc test all install uninstall reinstall clean distclean configure diff --git a/_oasis b/_oasis index 5c9b286..f7b2115 100644 --- a/_oasis +++ b/_oasis @@ -7,6 +7,7 @@ License: BSD-3-clause Plugins: META (0.3), DevFiles (0.3) BuildTools: ocamlbuild AlphaFeatures: ocamlbuild_more_args +XDevFilesEnableMakefile: false Library redis Path: src diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..76e6fde --- /dev/null +++ b/docs/index.html @@ -0,0 +1,13 @@ + + + ocaml-redis API documentation + + + +

ocaml-redis API documentation

+ + + diff --git a/docs/style.css b/docs/style.css new file mode 100644 index 0000000..37b6175 --- /dev/null +++ b/docs/style.css @@ -0,0 +1,97 @@ +/* A style for ocamldoc. Daniel C. Buenzli */ + +/* Reset a few things. */ +html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre, +a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp, +small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset, +form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td +{ margin: 0; padding: 0; border: 0 none; outline: 0; font-size: 100%; + font-weight: inherit; font-style:inherit; font-family:inherit; + line-height: inherit; vertical-align: baseline; text-align:inherit; + color:inherit; background: transparent; } + +table { border-collapse: collapse; border-spacing: 0; } + +/* Basic page layout */ + +body { font: normal 10pt/1.375em helvetica, arial, sans-serif; text-align:left; + margin: 1.375em 10%; min-width: 40ex; max-width: 72ex; + color: black; background: transparent /* url(line-height-22.gif) */; } + +b { font-weight: bold } +em { font-style: italic } + +tt, code, pre { font-family: WorkAroundWebKitAndMozilla, monospace; + font-size: 1em; } +pre code { font-size : inherit; } +.codepre { margin-bottom:1.375em /* after code example we introduce space. */ } + +.superscript,.subscript +{ font-size : 0.813em; line-height:0; margin-left:0.4ex;} +.superscript { vertical-align: super; } +.subscript { vertical-align: sub; } + +/* ocamldoc markup workaround hacks */ + + + +hr, hr + br, div + br, center + br, span + br, ul + br, ol + br, pre + br +{ display: none } /* annoying */ + +div.info + br { display:block} + +.codepre br + br { display: none } +h1 { margin-bottom:1.375em} /* Toplevel module description */ + +/* Sections and document divisions */ + +/* .navbar { margin-bottom: -1.375em } */ +h1 { font-weight: bold; font-size: 1.5em; /* margin-top:1.833em; */ + margin-top:0.917em; padding-top:0.875em; + border-top-style:solid; border-width:1px; border-color:#AAA; } +h2 { font-weight: bold; font-size: 1.313em; margin-top: 1.048em } +h3 { font-weight: bold; font-size: 1.125em; margin-top: 1.222em } +h3 { font-weight: bold; font-size: 1em; margin-top: 1.375em} +h4 { font-style: italic; } + +/* Used by OCaml's own library documentation. */ + h6 { font-weight: bold; font-size: 1.125em; margin-top: 1.222em } + .h7 { font-weight: bold; font-size: 1em; margin-top: 1.375em } + +p { margin-top: 1.375em } +pre { margin-top: 1.375em } +.info { margin: 0.458em 0em -0.458em 2em;}/* Description of types values etc. */ +td .info { margin:0; padding:0; margin-left: 2em;} /* Description in indexes */ + +ul, ol { margin-top:0.688em; padding-bottom:0.687em; + list-style-position:outside} +ul + p, ol + p { margin-top: 0em } +ul { list-style-type: square } + + +/* h2 + ul, h3 + ul, p + ul { } */ +ul > li { margin-left: 1.375em; } +ol > li { margin-left: 1.7em; } +/* Links */ + +a, a:link, a:visited, a:active, a:hover { color : #00B; text-decoration: none } +a:hover { text-decoration : underline } +*:target {background-color: #FFFF99;} /* anchor highlight */ + +/* Code */ + +.keyword { font-weight: bold; } +.comment { color : red } +.constructor { color : green } +.string { color : brown } +.warning { color : red ; font-weight : bold } + +/* Functors */ + +.paramstable { border-style : hidden ; padding-bottom:1.375em} +.paramstable code { margin-left: 1ex; margin-right: 1ex } +.sig_block {margin-left: 1em} + +/* Images */ + +img { margin-top: 1.375em } \ No newline at end of file diff --git a/setup.ml b/setup.ml index df69a83..8ef4bda 100644 --- a/setup.ml +++ b/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.3.1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: 9a60dba87a09f90e22c92be6951bbf32) *) +(* DO NOT EDIT (digest: 5a213d8b42be34430bc34ca5d822ef74) *) (* Regenerated by OASIS v0.4.5 Visit http://oasis.forge.ocamlcore.org for more information and @@ -7284,7 +7284,7 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.4.5"; - oasis_digest = Some "\012¨ß!ªð\018\129\004YÂh_\000¦\020"; + oasis_digest = Some "û>\1387\næ\130º\031l\146ù\023v\138\136"; oasis_exec = None; oasis_setup_args = []; setup_update = false diff --git a/src/cache.mli b/src/cache.mli index fddfc79..9854fd9 100644 --- a/src/cache.mli +++ b/src/cache.mli @@ -1,3 +1,6 @@ +(** + Cache module +*) module Make(IO : S.IO)(Client : S.Client with module IO = IO)(Params : S.Cache_params) : S.Cache with module IO = IO with module Client = Client diff --git a/src/client.ml b/src/client.ml index 6a59c29..166a1ae 100644 --- a/src/client.ml +++ b/src/client.ml @@ -2,8 +2,6 @@ This has only been tested with Redis 2.2, but will probably work for >= 2.0 **) - -(* Make communication module *) module Make(IO : S.IO) = struct module IO = IO diff --git a/src/client.mli b/src/client.mli index a4a93bb..88acd9a 100644 --- a/src/client.mli +++ b/src/client.mli @@ -1,7 +1,4 @@ -(** Bindings for redis. - - This has only been tested with Redis 2.2, but will probably work for >= 2.0 - **) - -(* Make communication module *) +(** + Redis client + *) module Make(IO : S.IO) : S.Client with module IO = IO diff --git a/src/mutex.mli b/src/mutex.mli index 93ad99f..9539a91 100644 --- a/src/mutex.mli +++ b/src/mutex.mli @@ -1,3 +1,6 @@ +(** + Mutex manager +*) module Make(IO : S.IO)(Client : S.Client with module IO = IO) : S.Mutex with module IO = IO with module Client = Client diff --git a/src/redis_sync.mli b/src/redis_sync.mli index f1fc954..807dc1f 100644 --- a/src/redis_sync.mli +++ b/src/redis_sync.mli @@ -1,3 +1,7 @@ +(** + Blocking client for Redis +*) + module IO : S.IO module Client : S.Client with module IO = IO diff --git a/src/s.mli b/src/s.mli index 36b63c0..5c005e2 100644 --- a/src/s.mli +++ b/src/s.mli @@ -41,6 +41,8 @@ end module type Client = sig module IO : IO + (** {6 Types and exceptions } *) + type reply = [ | `Status of string | `Error of string @@ -57,77 +59,89 @@ module type Client = sig stream : reply list IO.stream; } - (* error responses from server *) + (** Error responses from server *) exception Error of string - (* these signal protocol errors *) + (** Protocol errors *) exception Unexpected of reply exception Unrecognized of string * string (* explanation, data *) - (* server connection info *) + (** Server connection info *) type connection_spec = { host : string; port : int; } - (* possible bit operations *) + (** Possible BITOP operations *) type bit_operation = AND | OR | XOR | NOT + + (** {6 Connection handling } *) + val connect : connection_spec -> connection IO.t val disconnect : connection -> unit IO.t val with_connection : connection_spec -> (connection -> 'a IO.t) -> 'a IO.t val stream : connection -> reply list IO.stream - (* Raises Error if password is invalid. *) + (** {6 Connection commands } *) + + (** Authenticate to server. *) val auth : connection -> string -> unit IO.t + (** Echo given string. *) val echo : connection -> string -> string option IO.t + + (** Ping connection; returns [ true ] if ping was successfull. *) val ping : connection -> bool IO.t + + (** Close connection. *) val quit : connection -> unit IO.t - (* Switch to a different db; raises Error if index is invalid. *) + (** Switch to a different db; raises {!Error} if index is invalid. *) val select : connection -> int -> unit IO.t - (** Generic key commands *) + (** {6 Keys commands} *) - (* Returns the number of keys removed. *) + (** Delete a key; returns the number of keys removed. *) val del : connection -> string list -> int IO.t + (** Determine if a key exists. *) val exists : connection -> string -> bool IO.t - (* Returns true if timeout (in seconds) was set, false otherwise. *) + (** Set a key's time to live in seconds; returns [ true ] if timeout was set, false otherwise. *) val expire : connection -> string -> int -> bool IO.t - (* Returns true if timeout (in milliseconds) was set, false otherwise. *) + (** Set a key's time to live in milliseconds; returns [ true ] if timeout was set, false otherwise. *) val pexpire : connection -> string -> int -> bool IO.t - (* Like "expire" but with absolute (Unix) time; the time is truncated to the nearest second. *) + (** Set the expiration for a key as a UNIX timestamp, the time is truncated to the nearest second; returns [ true ] if timeout was set, [ false ] otherwise. *) val expireat : connection -> string -> float -> bool IO.t - (* Like "pexpire" but with absolute (Unix) time in milliseconds. *) + (** Set the expiration for a key as a UNIX timestamp in milliseconds; returns [ true ] if timeout was set, [ false ] otherwise. *) val pexpireat : connection -> string -> int -> bool IO.t - (* Probably not a good idea to use this in production; see Redis documentation. *) + (** Find all keys matching the given pattern. *) val keys : connection -> string -> string list IO.t - (* Cursor based iteration through all keys in database. *) + (** Incrementally iterate the keys space; see tests for usage example. *) val scan : ?pattern:string -> ?count:int -> connection -> int -> (int * string list) IO.t - (* Move key to a different db; returns true if key was moved, false otherwise. *) + (** Move key to a different db; returns [ true ] if key was moved, [ false ] otherwise. *) val move : connection -> string -> int -> bool IO.t - (* Remove timeout on key; returns true if timeout was removed, false otherwise. *) + (** Remove timeout on key; returns [ true ] if timeout was removed, [ false ] otherwise. *) val persist : connection -> string -> bool IO.t - (* returns none if db is empty. *) + (** Return a random key from the keyspace; returns [ None ] if db is empty. *) val randomkey : connection -> string option IO.t - (* Raises Error if key doesn't exist. *) + (** Rename a key; raises {!Error} if key doesn't exist. *) val rename : connection -> string -> string -> unit IO.t - (* Raises Error if key doesn't exist; returns true if key was renamed, false if newkey already exists. *) + (** Rename a key, only if the new key does not exist; returns [ true ] if key was renamed, [ false ] if newkey already exists. *) val renamenx : connection -> string -> string -> bool IO.t + (** Sort elements in a list, set or sorted set; return sorted list of items. *) val sort : connection -> ?by:string -> @@ -135,6 +149,7 @@ module type Client = sig ?get:'a list -> ?order:[< `Asc | `Desc ] -> ?alpha:bool -> string -> string list IO.t + (** Sort and store elements in a list, set or sorted set; returns length of sorted items list which was stored. *) val sort_and_store : connection -> ?by:string -> @@ -143,116 +158,141 @@ module type Client = sig ?order:[< `Asc | `Desc ] -> ?alpha:bool -> string -> string -> int IO.t - (* Returns None if key doesn't exist or doesn't have a timeout. *) + (** Time to live for a key in seconds; returns [ None ] if key doesn't exist or doesn't have a timeout. *) val ttl : connection -> string -> int option IO.t - (* Returns None if key doesn't exist or doesn't have a timeout. *) + (** Time to live for a key in milliseconds; returns [ None ] if key doesn't exist or doesn't have a timeout. *) val pttl : connection -> string -> int option IO.t - (* TYPE is a reserved word in ocaml *) + (** Determine the type stored as key. *) val type_of : connection -> string -> [> `Hash | `List | `None | `String | `Zset ] IO.t - (* Serialize value stored at key in a Redis-specific format *) + (** Return a serialized version of the value stored at the specified key; returns [ None ] if key doesn't exist. *) val dump: connection -> string -> string option IO.t - (* Create a key with serialized value (obtained via DUMP) *) + (** Create a key with serialized value (obtained via DUMP). *) val restore: connection -> string -> int -> string -> unit IO.t + (** Inspect the internals of Redis objects; returns the number of references of the value associated with the specified key. *) val object_refcount: connection -> string -> int option IO.t + (** Inspect the internals of Redis objects; returns the kind of internal representation used in order to store the value associated with a key. *) val object_encoding: connection -> string -> string option IO.t + (** Inspect the internals of Redis objects; returns the number of seconds since the object stored at the specified key is idle. *) val object_idletime: connection -> string -> int option IO.t - (** String commands *) + (** {6 String commands} *) - (* Returns length of string after append. *) + (** Append a value to a key; returns length of string after append. *) val append : connection -> string -> string -> int IO.t + (** Sets or clears the bit at offset in the string value stored at key. *) + val setbit : connection -> string -> int -> int -> int IO.t + + (** Returns the bit value at offset in the string value stored at key. *) + val getbit : connection -> string -> int -> int IO.t + + (** Perform a bitwise operation between multiple keys (containing string values) and store the result in the destination key. + See {!bit_operation} type for available operations. *) + val bitop : connection -> bit_operation -> string -> string list -> int IO.t + + (** Count the number of set bits (population counting) in a string. *) + val bitcount : ?first:int -> ?last:int -> connection -> string -> int IO.t + + (** Return the position of the first bit set to 1 or 0 in a string. *) + val bitpos : ?first:int -> ?last:int -> connection -> string -> int -> int IO.t + + (** Decrements the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. *) val decr : connection -> string -> int IO.t + (** Decrements the number stored at key by decrement. If the key does not exist, it is set to 0 before performing the operation. *) val decrby : connection -> string -> int -> int IO.t + (** Get the value of key. *) val get : connection -> string -> string option IO.t - (* Out of range arguments are handled by limiting to valid range. *) + (** Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). *) val getrange : connection -> string -> int -> int -> string option IO.t - (* Set value and return old value. Raises Error when key exists but isn't a string. *) + (** Atomically sets key to value and returns the old value stored at key. Returns [ None ] when key exists but does not hold a string value. *) val getset : connection -> string -> string -> string option IO.t + (** Increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. *) val incr : connection -> string -> int IO.t + (** Increments the number stored at key by increment. If the key does not exist, it is set to 0 before performing the operation. *) val incrby : connection -> string -> int -> int IO.t + (** Increment the string representing a floating point number stored at key by the specified increment. If the key does not exist, it is set to 0 before performing the operation. *) val incrbyfloat : connection -> string -> float -> float IO.t + (** Returns the values of all specified keys. *) val mget : connection -> string list -> string option list IO.t - (* This is atomic: either all keys are set or none are. *) + (** Sets the given keys to their respective values. *) val mset : connection -> (string * string) list -> unit IO.t - (* Like MSET, this is atomic. If even a single key exists, no operations will be performed. - Returns true if all keys were set, false otherwise. *) + (** Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists. *) val msetnx : connection -> (string * string) list -> bool IO.t + (** Set key to hold the string value. *) val set : connection -> string -> string -> unit IO.t + (** Set key to hold the string value and set key to timeout after a given number of seconds. *) val setex : connection -> string -> int -> string -> unit IO.t + (** PSETEX works exactly like SETEX with the sole difference that the expire time is specified in milliseconds instead of seconds. *) val psetex : connection -> string -> int -> string -> unit IO.t - (* Returns true if key was set, false otherwise. *) + (** Set key to hold string value if key does not exist. *) val setnx : connection -> string -> string -> bool IO.t - (* If offset > length, string will be padded with 0-bytes. Returns length of string after modification. *) + (** Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. *) val setrange : connection -> string -> int -> string -> int IO.t + (** Returns the length of the string value stored at key. An error is returned when key holds a non-string value. *) val strlen : connection -> string -> int IO.t - (** Bitwise commands *) - - val setbit : connection -> string -> int -> int -> int IO.t - - val getbit : connection -> string -> int -> int IO.t - - val bitop : connection -> bit_operation -> string -> string list -> int IO.t - - val bitcount : ?first:int -> ?last:int -> connection -> string -> int IO.t - - val bitpos : ?first:int -> ?last:int -> connection -> string -> int -> int IO.t - - (** Hash commands *) + (** {6 Hash commands} *) - (* Returns true if field exists and was deleted, false otherwise. *) + (** Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored. *) val hdel : connection -> string -> string -> bool IO.t + (** Returns if field is an existing field in the hash stored at key. *) val hexists : connection -> string -> string -> bool IO.t + (** Returns the value associated with field in the hash stored at key. *) val hget : connection -> string -> string -> string option IO.t + (** Returns all fields and values of the hash stored at key. *) val hgetall : connection -> string -> (string * string) list IO.t - (* Raises error if field already contains a non-numeric value. *) + (** Increments the number stored at field in the hash stored at key by increment. *) val hincrby : connection -> string -> string -> int -> int IO.t + (** Returns all field names in the hash stored at key. *) val hkeys : connection -> string -> string list IO.t + (** Returns the number of fields contained in the hash stored at key. *) val hlen : connection -> string -> int IO.t + (** Returns the values associated with the specified fields in the hash stored at key. *) val hmget : connection -> string -> string list -> string option list IO.t + (** Sets the specified fields to their respective values in the hash stored at key. *) val hmset : connection -> string -> (string * string) list -> unit IO.t - (* Returns true if field was added, false otherwise. *) + (** Sets field in the hash stored at key to value. *) val hset : connection -> string -> string -> string -> bool IO.t - (* Returns true if field was set, false otherwise. *) + (** Sets field in the hash stored at key to value, only if field does not yet exist. *) val hsetnx : connection -> string -> string -> string -> bool IO.t + (** Returns all values in the hash stored at key. *) val hvals : connection -> string -> string list IO.t - (** List commands *) + (** {6 List commands} *) (* Blocks while all of the lists are empty. Set timeout to number of seconds OR 0 to block indefinitely. *) val blpop : connection -> string list -> int -> (string * string) option IO.t @@ -302,7 +342,7 @@ module type Client = sig val rpushx : connection -> string -> string -> int IO.t - (** Set commands *) + (** {6 Set commands} *) (* Returns true if member was added, false otherwise. *) val sadd : connection -> string -> string -> bool IO.t @@ -341,7 +381,7 @@ module type Client = sig (* Like SUNION, but store result in destination. Returns size of result. *) val sunionstore : connection -> string -> string list -> int IO.t - (** Pub/sub commands *) + (** {6 Pub/sub commands} *) (* Post a message to a channel. Returns number of clients that received the message. *) val publish : connection -> string -> string -> int IO.t @@ -364,7 +404,7 @@ module type Client = sig (* Unsubscribes the client from the given patterns. *) val punsubscribe : connection -> string list -> unit IO.t - (** Sorted Set commands *) + (** {6 Sorted set commands} *) (* Add one or more members to a sorted set, or update its score if it already exists. *) val zadd : connection -> string -> (int * string) list -> int IO.t @@ -378,7 +418,7 @@ module type Client = sig (* Remove one or more members from a sorted set. *) val zrem : connection -> string list -> int IO.t - (** Transaction commands *) + (** {6 Transaction commands} *) (* Marks the start of a transaction block. Subsequent commands will be queued for atomic execution using EXEC. *) val multi : connection -> unit IO.t @@ -397,7 +437,7 @@ module type Client = sig val queue : (unit -> 'a IO.t) -> unit IO.t - (** Scripting commands *) + (** {6 Scripting commands} *) (* Load the specified Lua script into the script cache. Returns the SHA1 digest of the script for use with EVALSHA. *) val script_load : connection -> string -> string IO.t @@ -408,7 +448,7 @@ module type Client = sig (* Evaluates a script cached on the server side by its SHA1 digest. *) val evalsha : connection -> string -> string list -> string list -> reply IO.t - (** Server *) + (** {6 Server} *) val bgrewriteaof : connection -> unit IO.t