package redis-sync

  1. Overview
  2. Docs

Module Redis_sync.ClientSource

Sourcemodule IO = IO
Sourcemodule StringBound : sig ... end
Sourcemodule FloatBound : sig ... end

Types and exceptions

Sourcetype redirection = {
  1. slot : int;
  2. host : string;
  3. port : int;
}
Sourcetype reply = [
  1. | `Status of string
  2. | `Error of string
  3. | `Int of int
  4. | `Int64 of Int64.t
  5. | `Bulk of string option
  6. | `Multibulk of reply list
  7. | `Ask of redirection
  8. | `Moved of redirection
]
Sourceval string_of_reply : reply -> string

For debugging purpose

Sourcetype connection_spec = {
  1. host : string;
  2. port : int;
}

Server connection info

Sourcemodule SlotMap : Map.S with type key = int
Sourcetype cluster_connections = private {
  1. mutable connections_spec : connection_spec SlotMap.t;
  2. mutable connections : connection ConnectionSpecMap.t;
}
Sourceand connection = private {
  1. fd : IO.fd;
  2. in_ch : IO.in_channel;
  3. out_ch : IO.out_channel;
  4. stream : reply list IO.stream;
  5. cluster : cluster_connections;
}
Sourceexception Redis_error of string

Error responses from server

Sourceexception Unexpected of reply

Protocol errors

Sourceexception Unrecognized of string * string
Sourcetype bit_operation =
  1. | AND
  2. | OR
  3. | XOR
  4. | NOT

Possible BITOP operations

Connection handling

Sourceval disconnect : connection -> unit IO.t
Sourceval with_connection : connection_spec -> (connection -> 'a IO.t) -> 'a IO.t
Sourceval stream : connection -> reply list IO.stream

Connection commands

Sourceval auth : connection -> string -> unit IO.t

Authenticate to server.

Sourceval echo : connection -> string -> string option IO.t

Echo given string.

Sourceval ping : connection -> bool IO.t

Ping connection; returns true if ping was successfull.

Sourceval quit : connection -> unit IO.t

Close connection.

Sourceval select : connection -> int -> unit IO.t

Switch to a different db; raises Error if index is invalid.

Sourceval sentinel_masters : connection -> (string * string) list list IO.t

SENTINEL commands

Sourceval sentinel_get_master_addr_by_name : connection -> string -> (string * string) option IO.t

Keys commands

Sourceval del : connection -> string list -> int IO.t

Delete a key; returns the number of keys removed.

Sourceval exists : connection -> string -> bool IO.t

Determine if a key exists.

Sourceval expire : connection -> string -> int -> bool IO.t

Set a key's time to live in seconds; returns true if timeout was set, false otherwise.

Sourceval pexpire : connection -> string -> int -> bool IO.t

Set a key's time to live in milliseconds; returns true if timeout was set, false otherwise.

Sourceval expireat : connection -> string -> float -> bool IO.t

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.

Sourceval pexpireat : connection -> string -> int -> bool IO.t

Set the expiration for a key as a UNIX timestamp in milliseconds; returns true if timeout was set, false otherwise.

Sourceval keys : connection -> string -> string list IO.t

Find all keys matching the given pattern.

Sourceval scan : ?pattern:string -> ?count:int -> connection -> int -> (int * string list) IO.t

Incrementally iterate the keys space; see tests for usage example.

Sourceval move : connection -> string -> int -> bool IO.t

Move key to a different db; returns true if key was moved, false otherwise.

Sourceval persist : connection -> string -> bool IO.t

Remove timeout on key; returns true if timeout was removed, false otherwise.

Sourceval randomkey : connection -> string option IO.t

Return a random key from the keyspace; returns None if db is empty.

Sourceval rename : connection -> string -> string -> unit IO.t

Rename a key; raises Error if key doesn't exist.

Sourceval renamenx : connection -> string -> string -> bool IO.t

Rename a key, only if the new key does not exist; returns true if key was renamed, false if newkey already exists.

Sourceval sort : connection -> ?by:string -> ?limit:(int * int) -> ?get:'a list -> ?order:[< `Asc | `Desc ] -> ?alpha:bool -> string -> string list IO.t

Sort elements in a list, set or sorted set; return sorted list of items.

Sourceval sort_and_store : connection -> ?by:string -> ?limit:(int * int) -> ?get:'a list -> ?order:[< `Asc | `Desc ] -> ?alpha:bool -> string -> string -> int IO.t

Sort and store elements in a list, set or sorted set; returns length of sorted items list which was stored.

Sourceval ttl : connection -> string -> int option IO.t

Time to live for a key in seconds; returns None if key doesn't exist or doesn't have a timeout.

Sourceval pttl : connection -> string -> int option IO.t

Time to live for a key in milliseconds; returns None if key doesn't exist or doesn't have a timeout.

Sourceval type_of : connection -> string -> [> `Hash | `List | `None | `String | `Zset ] IO.t

Determine the type stored as key.

Sourceval dump : connection -> string -> string option IO.t

Return a serialized version of the value stored at the specified key; returns None if key doesn't exist.

Sourceval restore : connection -> string -> int -> string -> unit IO.t

Create a key with serialized value (obtained via DUMP).

Sourceval migrate : connection -> ?copy:bool -> ?replace:bool -> string -> int -> string -> int -> int -> unit IO.t

Atomically transfer a key from a source Redis instance to a destination Redis instance.

Sourceval object_refcount : connection -> string -> int option IO.t

Inspect the internals of Redis objects; returns the number of references of the value associated with the specified key.

Sourceval object_encoding : connection -> string -> string 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.

Sourceval object_idletime : connection -> string -> int option IO.t

Inspect the internals of Redis objects; returns the number of seconds since the object stored at the specified key is idle.

String commands

Sourceval append : connection -> string -> string -> int IO.t

Append a value to a key; returns length of string after append.

Sourceval setbit : connection -> string -> int -> int -> int IO.t

Sets or clears the bit at offset in the string value stored at key.

Sourceval getbit : connection -> string -> int -> int IO.t

Returns the bit value at offset in the string value stored at key.

Sourceval bitop : connection -> bit_operation -> string -> string list -> 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.

Sourceval bitcount : ?first:int -> ?last:int -> connection -> string -> int IO.t

Count the number of set bits (population counting) in a string.

Sourceval bitpos : ?first:int -> ?last:int -> connection -> string -> int -> int IO.t

Return the position of the first bit set to 1 or 0 in a string.

Sourceval decr : connection -> string -> 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.

Sourceval decrby : connection -> string -> int -> 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.

Sourceval get : connection -> string -> string option IO.t

Get the value of key.

Sourceval getrange : connection -> string -> int -> int -> string option IO.t

Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive).

Sourceval getset : connection -> string -> string -> string option IO.t

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.

Sourceval incr : connection -> string -> int 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.

Sourceval incrby : connection -> string -> int -> 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.

Sourceval incrbyfloat : connection -> string -> float -> float 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.

Sourceval mget : connection -> string list -> string option list IO.t

Returns the values of all specified keys.

Sourceval mset : connection -> (string * string) list -> unit IO.t

Sets the given keys to their respective values.

Sourceval msetnx : connection -> (string * string) list -> bool IO.t

Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists.

Sourceval set : connection -> ?ex:int -> ?px:int -> ?nx:bool -> ?xx:bool -> string -> string -> bool IO.t

Set key to hold the string value.

Sourceval setex : connection -> string -> int -> string -> unit IO.t

Set key to hold the string value and set key to timeout after a given number of seconds.

Sourceval psetex : 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.

Sourceval setnx : connection -> string -> string -> bool IO.t

Set key to hold string value if key does not exist.

Sourceval setrange : connection -> string -> int -> string -> int IO.t

Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value.

Sourceval strlen : connection -> 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.

Hash commands

Sourceval hdel : connection -> string -> string -> bool IO.t

Removes the specified fields from the hash stored at key. Specified fields that do not exist within this hash are ignored.

Sourceval hexists : connection -> string -> string -> bool IO.t

Returns if field is an existing field in the hash stored at key.

Sourceval hget : connection -> string -> string -> string option IO.t

Returns the value associated with field in the hash stored at key.

Sourceval hgetall : connection -> string -> (string * string) list IO.t

Returns all fields and values of the hash stored at key.

Sourceval hincrby : connection -> string -> string -> int -> int IO.t

Increments the number stored at field in the hash stored at key by increment.

Sourceval hincrbyfloat : connection -> string -> string -> float -> float IO.t

Increments the number stored at field in the hash stored at key by increment.

Sourceval hkeys : connection -> string -> string list IO.t

Returns all field names in the hash stored at key.

Sourceval hlen : connection -> string -> int IO.t

Returns the number of fields contained in the hash stored at key.

Sourceval hmget : connection -> string -> string list -> string option list IO.t

Returns the values associated with the specified fields in the hash stored at key.

Sourceval hmset : connection -> string -> (string * string) list -> unit IO.t

Sets the specified fields to their respective values in the hash stored at key.

Sourceval hset : connection -> string -> string -> string -> bool IO.t

Sets field in the hash stored at key to value.

Sourceval hsetnx : connection -> string -> string -> string -> bool IO.t

Sets field in the hash stored at key to value, only if field does not yet exist.

Sourceval hstrlen : connection -> string -> string -> int IO.t

Get the length of the value of a hash field

Sourceval hscan : ?pattern:string -> ?count:int -> connection -> string -> int -> (int * (string * string) list) IO.t

Incrementally iterate hash fields and associated values

Sourceval hvals : connection -> string -> string list IO.t

Returns all values in the hash stored at key.

List commands

Sourceval blpop : connection -> string list -> int -> (string * string) option IO.t

Remove and get the first element in a list, or block until one is available

Sourceval brpop : connection -> string list -> int -> (string * string) option IO.t

Remove and get the last element in a list, or block until one is available

Sourceval brpoplpush : connection -> string -> string -> int -> string option IO.t

Pop a value from a list, push it to another list and return it; or block until one is available

Sourceval lindex : connection -> string -> int -> string option IO.t

Get an element from a list by its index

Sourceval linsert : connection -> string -> [< `After | `Before ] -> string -> string -> int option IO.t

Insert an element before or after another element in a list

Sourceval llen : connection -> string -> int IO.t

Get the length of a list

Sourceval lpop : connection -> string -> string option IO.t

Remove and get the first element in a list

Sourceval lpush : connection -> string -> string list -> int IO.t

Prepend one or multiple values to a list

Sourceval lpushx : connection -> string -> string list -> int IO.t

Prepend a value to a list, only if the list exists

Sourceval lrange : connection -> string -> int -> int -> string list IO.t

Get a range of elements from a list

Sourceval lrem : connection -> string -> int -> string -> int IO.t

Remove elements from a list

Sourceval lset : connection -> string -> int -> string -> unit IO.t

Set the value of an element in a list by its index

Sourceval ltrim : connection -> string -> int -> int -> unit IO.t

Trim a list to the specified range

Sourceval rpop : connection -> string -> string option IO.t

Remove and get the last element in a list

Sourceval rpoplpush : connection -> string -> string -> string option IO.t

Remove the last element in a list, prepend it to another list and return it

Sourceval rpush : connection -> string -> string list -> int IO.t

Append one or multiple values to a list

Sourceval rpushx : connection -> string -> string list -> int IO.t

Append a value to a list, only if the list exists

HyperLogLog commands

Sourceval pfadd : connection -> string -> string list -> bool IO.t

Adds values to the HyperLogLog data structure.

Sourceval pfcount : connection -> string list -> int IO.t

Returns the approximated cardinality of the union of the HyperLogLogs passed.

Sourceval pfmerge : connection -> string list -> unit IO.t

Merge multiple HyperLogLog values into an unique value that will approximate the cardinality of the union of the observed Sets of the source HyperLogLog structures.

Set commands

Sourceval sadd : connection -> string -> string -> bool IO.t
Sourceval scard : connection -> string -> int IO.t
Sourceval sdiff : connection -> string list -> string list IO.t
Sourceval sdiffstore : connection -> string -> string list -> int IO.t
Sourceval sinter : connection -> string list -> string list IO.t
Sourceval sinterstore : connection -> string -> string list -> int IO.t
Sourceval sismember : connection -> string -> string -> bool IO.t
Sourceval smembers : connection -> string -> string list IO.t
Sourceval smove : connection -> string -> string -> string -> bool IO.t
Sourceval spop : connection -> string -> string option IO.t
Sourceval srandmember : connection -> string -> string option IO.t
Sourceval srem : connection -> string -> string -> bool IO.t
Sourceval sunion : connection -> string list -> string list IO.t
Sourceval sunionstore : connection -> string -> string list -> int IO.t

Pub/sub commands

Sourceval publish : connection -> string -> string -> int IO.t
Sourceval pubsub_channels : connection -> string option -> reply list IO.t
Sourceval pubsub_numsub : connection -> string list -> reply list IO.t
Sourceval subscribe : connection -> string list -> unit IO.t
Sourceval unsubscribe : connection -> string list -> unit IO.t
Sourceval psubscribe : connection -> string list -> unit IO.t
Sourceval punsubscribe : connection -> string list -> unit IO.t

Sorted set commands

Sourceval zadd : connection -> ?x:[< `NX | `XX ] -> ?ch:bool -> string -> (float * string) list -> int IO.t
Sourceval zrange : connection -> ?withscores:bool -> string -> int -> int -> reply list IO.t
Sourceval zrevrange : connection -> ?withscores:bool -> string -> int -> int -> reply list IO.t
Sourceval zrangebyscore : connection -> ?withscores:bool -> ?limit:(int * int) -> string -> FloatBound.t -> FloatBound.t -> reply list IO.t
Sourceval zrangebylex : connection -> ?limit:(int * int) -> string -> StringBound.t -> StringBound.t -> reply list IO.t
Sourceval zrevrangebyscore : connection -> ?withscores:bool -> ?limit:(int * int) -> string -> FloatBound.t -> FloatBound.t -> reply list IO.t
Sourceval zrevrangebylex : connection -> ?limit:(int * int) -> string -> StringBound.t -> StringBound.t -> reply list IO.t
Sourceval zrem : connection -> string -> string list -> int IO.t
Sourceval zremrangebylex : connection -> string -> StringBound.t -> StringBound.t -> int IO.t
Sourceval zremrangebyscore : connection -> string -> FloatBound.t -> FloatBound.t -> int IO.t
Sourceval zremrangebyrank : connection -> string -> int -> int -> int IO.t
Sourceval zcard : connection -> string -> int IO.t
Sourceval zincrby : connection -> string -> float -> string -> float IO.t
Sourceval zscore : connection -> string -> string -> float option IO.t
Sourceval zcount : connection -> string -> FloatBound.t -> FloatBound.t -> int IO.t
Sourceval zlexcount : connection -> string -> StringBound.t -> StringBound.t -> int IO.t
Sourceval zrank : connection -> string -> string -> int option IO.t
Sourceval zrevrank : connection -> string -> string -> int option IO.t

Transaction commands

Sourceval multi : connection -> unit IO.t
Sourceval exec : connection -> reply list IO.t
Sourceval discard : connection -> unit IO.t
Sourceval watch : connection -> string list -> unit IO.t
Sourceval unwatch : connection -> unit IO.t
Sourceval queue : (unit -> 'a IO.t) -> unit IO.t

Scripting commands

Sourceval script_load : connection -> string -> string IO.t
Sourceval eval : connection -> string -> string list -> string list -> reply IO.t
Sourceval evalsha : connection -> string -> string list -> string list -> reply IO.t

Server

Sourceval bgrewriteaof : connection -> unit IO.t
Sourceval bgsave : connection -> unit IO.t
Sourceval config_resetstat : connection -> unit IO.t
Sourceval dbsize : connection -> int IO.t
Sourceval flushall : connection -> unit IO.t
Sourceval flushdb : connection -> unit IO.t
Sourceval info : connection -> (string * string) list IO.t
Sourceval lastsave : connection -> float IO.t
Sourceval role : connection -> reply list IO.t
Sourceval save : connection -> unit IO.t
Sourceval shutdown : connection -> unit IO.t
Sourcemodule MassInsert : sig ... end
OCaml

Innovation. Community. Security.