You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/redis.rb
+78-18Lines changed: 78 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,26 @@ def self.current=(redis)
26
26
27
27
includeMonitorMixin
28
28
29
+
# Create a new client instance
30
+
#
31
+
# @param [Hash] options
32
+
# @option options [String] :url (value of the environment variable REDIS_URL) a Redis URL, for a TCP connection: `redis://:[password]@[hostname]:[port]/[db]` (password, port and database are optional), for a unix socket connection: `unix://[path to Redis socket]`. This overrides all other options.
33
+
# @option options [String] :host ("127.0.0.1") server hostname
34
+
# @option options [Fixnum] :port (6379) server port
35
+
# @option options [String] :path path to server socket (overrides host and port)
36
+
# @option options [Float] :timeout (5.0) timeout in seconds
37
+
# @option options [Float] :connect_timeout (same as timeout) timeout for initial connect in seconds
38
+
# @option options [String] :password Password to authenticate against server
39
+
# @option options [Fixnum] :db (0) Database to select after initial connect
40
+
# @option options [Symbol] :driver Driver to use, currently supported: `:ruby`, `:hiredis`, `:synchrony`
41
+
# @option options [String] :id ID for the client connection, assigns name to current connection by sending `CLIENT SETNAME`
42
+
# @option options [Hash, Fixnum] :tcp_keepalive Keepalive values, if Fixnum `intvl` and `probe` are calculated based on the value, if Hash `time`, `intvl` and `probes` can be specified as a Fixnum
43
+
# @option options [Fixnum] :reconnect_attempts Number of attempts trying to connect
44
+
# @option options [Boolean] :inherit_socket (false) Whether to use socket in forked process or not
45
+
# @option options [Array] :sentinels List of sentinels to contact
46
+
# @option options [Symbol] :role (:master) Role to fetch via Sentinel, either `:master` or `:slave`
47
+
#
48
+
# @return [Redis] a new client instance
29
49
definitialize(options={})
30
50
@options=options.dup
31
51
@original_client=@client=Client.new(options)
@@ -368,8 +388,15 @@ def expireat(key, unix_time)
368
388
# Get the time to live (in seconds) for a key.
369
389
#
370
390
# @param [String] key
371
-
# @return [Fixnum] remaining time to live in seconds, or -1 if the
372
-
# key does not exist or does not have a timeout
391
+
# @return [Fixnum] remaining time to live in seconds.
392
+
#
393
+
# In Redis 2.6 or older the command returns -1 if the key does not exist or if
394
+
# the key exist but has no associated expire.
395
+
#
396
+
# Starting with Redis 2.8 the return value in case of error changed:
397
+
#
398
+
# - The command returns -2 if the key does not exist.
399
+
# - The command returns -1 if the key exists but has no associated expire.
0 commit comments