oxblood 0.1.0.dev5 → 0.1.0.dev6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b3e70584c6264f36457da12558ba76dcabc4b19
4
- data.tar.gz: 06a8d8e83f0e9d9a68790126fb1324023cd86c08
3
+ metadata.gz: 5d4ee25bdc593d1e5add8d8a72fe3a5672c761be
4
+ data.tar.gz: 83eb492c6fa4754533db829df5a8ae73502393cb
5
5
  SHA512:
6
- metadata.gz: 36e9a9993f99b8fc11ebb7ee0208964c7eaedf08ce300f3b0061844dfe3d080e25d0d7b66353564b9a73c9c3af624b9e3f18773cbfb2c2ff0fac067b93e7a4fb
7
- data.tar.gz: b8612141ca6b893edc340ce5247cf7f2a2b3429baf1b0ccd4688deb1fe2c77fd586910dba1fcb5658a6450c18472b7ba5f4efb2f50e4d8278846c8f22f66e6f7
6
+ metadata.gz: e92b901aa353d3db7398918a44721fa85d84f9b835c0478841402b0bc82afccd0435228800d19dcf7745e1f3f5ce03fcafe26881c2a6d72ef5f1be0652122ddf
7
+ data.tar.gz: 63d6b37b92ed32d333223afafaa776ae31fa07f49ed777ccb75fb3c8191665221360de1604fa24488c074ab182bedf4a43696254a0dbaae189d8113c1e479119
data/README.md CHANGED
@@ -1,12 +1,18 @@
1
1
  # Oxblood
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/oxblood.svg)](https://badge.fury.io/rb/oxblood)
4
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/etehtsea/oxblood/master/frames)
4
5
  [![Code Climate](https://codeclimate.com/github/etehtsea/oxblood/badges/gpa.svg)](https://codeclimate.com/github/etehtsea/oxblood)
5
6
  [![Test Coverage](https://codeclimate.com/github/etehtsea/oxblood/badges/coverage.svg)](https://codeclimate.com/github/etehtsea/oxblood/coverage)
6
7
  [![Issue Count](https://codeclimate.com/github/etehtsea/oxblood/badges/issue_count.svg)](https://codeclimate.com/github/etehtsea/oxblood)
7
8
 
8
9
  An experimental Redis Ruby client.
9
10
 
11
+ ## Compatibility
12
+
13
+ - Ruby 2.2.2+
14
+ - JRuby 9k+
15
+
10
16
  ## Usage
11
17
 
12
18
  ### Standalone
@@ -72,6 +72,9 @@ module Oxblood
72
72
  # @param [Integer] increment by value
73
73
  #
74
74
  # @return [String] the value of field after the increment
75
+ # @return [RError] field contains a value of the wrong type (not a string).
76
+ # Or the current field content or the specified increment are not parsable
77
+ # as a double precision floating point number.
75
78
  def hincrbyfloat(key, field, increment)
76
79
  run(:HINCRBYFLOAT, key, field, increment)
77
80
  end
@@ -171,13 +174,6 @@ module Oxblood
171
174
  run(:HVALS, key)
172
175
  end
173
176
 
174
- # Incrementally iterate hash fields and associated values
175
- # @see http://redis.io/commands/hscan
176
- #
177
- # @todo Implement this command
178
- def hscan(key, cursor)
179
- end
180
-
181
177
  # ------------------ Strings ---------------------
182
178
 
183
179
  # ------------------ Connection ---------------------
@@ -188,6 +184,8 @@ module Oxblood
188
184
  # @param [String] password
189
185
  #
190
186
  # @return [String] 'OK'
187
+ # @return [RError] if wrong password was passed or server does not require
188
+ # password
191
189
  def auth(password)
192
190
  run(:AUTH, password)
193
191
  end
@@ -231,6 +229,7 @@ module Oxblood
231
229
  # @param [Integer] index database to switch
232
230
  #
233
231
  # @return [String] 'OK'
232
+ # @return [RError] if wrong index was passed
234
233
  def select(index)
235
234
  run(:SELECT, index)
236
235
  end
@@ -242,9 +241,10 @@ module Oxblood
242
241
  # @see http://redis.io/commands/info
243
242
  #
244
243
  # @param [String] section used to select a specific section of information
244
+ #
245
+ # @return [String] raw redis server response as a collection of text lines.
245
246
  def info(section = nil)
246
247
  section ? run(:INFO, section) : run(:INFO)
247
- # FIXME: Parse response
248
248
  end
249
249
 
250
250
  # ------------------ Keys ------------------------
@@ -259,12 +259,26 @@ module Oxblood
259
259
  run(*keys.unshift(:DEL))
260
260
  end
261
261
 
262
- # Find all keys matching the given pattern
263
- # @see http://redis.io/commands/keys
262
+ # Return a serialized version of the value stored at specified key.
263
+ # @see http://redis.io/commands/dump
264
264
  #
265
- # @param [String] pattern used to match keys
266
- def keys(pattern)
267
- run(:KEYS, pattern)
265
+ # @param [String] key
266
+ #
267
+ # @return [String] serialized value
268
+ def dump(key)
269
+ run(:DUMP, key)
270
+ end
271
+
272
+ # Determine if a key exists
273
+ # @see http://redis.io/commands/exists
274
+ #
275
+ # @param [String, Array<String>] keys to check
276
+ #
277
+ # @return [Integer] the number of keys existing among the ones specified as
278
+ # arguments. Keys mentioned multiple times and existing are counted
279
+ # multiple times.
280
+ def exists(*keys)
281
+ run(*keys.unshift(:EXISTS))
268
282
  end
269
283
 
270
284
  # Set a key's time to live in seconds
@@ -279,6 +293,170 @@ module Oxblood
279
293
  run(:EXPIRE, key, seconds)
280
294
  end
281
295
 
296
+ # Set the expiration for a key as a UNIX timestamp
297
+ # @see http://redis.io/commands/expireat
298
+ #
299
+ # @param [String] key
300
+ # @param [Integer] timestamp in UNIX format
301
+ #
302
+ # @return [Integer] 1 if the timeout was set. 0 if key does not exist or
303
+ # the timeout could not be set.
304
+ def expireat(key, timestamp)
305
+ run(:EXPIREAT, key, timestamp)
306
+ end
307
+
308
+ # Find all keys matching the given pattern
309
+ # @see http://redis.io/commands/keys
310
+ #
311
+ # @param [String] pattern used to match keys
312
+ def keys(pattern)
313
+ run(:KEYS, pattern)
314
+ end
315
+
316
+ # Move a key to another database
317
+ # @see http://redis.io/commands/move
318
+ #
319
+ # @param [String] key
320
+ # @param [Integer] db index
321
+ #
322
+ # @return [Integer] 1 if key was moved and 0 otherwise.
323
+ def move(key, db)
324
+ run(:MOVE, key, db)
325
+ end
326
+
327
+ # Inspect the internals of Redis objects
328
+ # @see http://redis.io/commands/object
329
+ #
330
+ # @param [String] subcommand `REFCOUNT`, `ENCODING`, `IDLETIME`
331
+ # @param [String] key
332
+ #
333
+ # @return [Integer] in case of `REFCOUNT` and `IDLETIME` subcommands
334
+ # @return [String] in case of `ENCODING` subcommand
335
+ # @return [nil] if object you try to inspect is missing
336
+ def object(subcommand, key)
337
+ run(:OBJECT, subcommand, key)
338
+ end
339
+
340
+ # Remove expiration from a key
341
+ # @see http://redis.io/commands/persist
342
+ # @param [String] key
343
+ #
344
+ # @return [Integer] 1 if the timeout was removed and 0 otherwise
345
+ def persist(key)
346
+ run(:PERSIST, key)
347
+ end
348
+
349
+ # Set a key's time to live in milliseconds
350
+ # @see http://redis.io/commands/pexpire
351
+ #
352
+ # @param [String] key
353
+ # @param [Integer] milliseconds
354
+ #
355
+ # @return [Integer] 1 if the timeout was set and 0 otherwise
356
+ def pexpire(key, milliseconds)
357
+ run(:PEXPIRE, key, milliseconds)
358
+ end
359
+
360
+ # Set the expiration for a key as a UNIX timestamp specified in milliseconds
361
+ # @see http://redis.io/commands/pexpireat
362
+ #
363
+ # @param [String] key
364
+ # @param [Integer] timestamp in milliseconds
365
+ #
366
+ # @return [Integer] 1 if the timeout was set and 0 otherwise
367
+ def pexpireat(key, timestamp)
368
+ run(:PEXPIREAT, key, timestamp)
369
+ end
370
+
371
+ # Get the time to live for a key in milliseconds
372
+ # @see http://redis.io/commands/pttl
373
+ #
374
+ # @param [String] key
375
+ #
376
+ # @return [Integer] TTL in milliseconds, or a negative value in order to
377
+ # signal an error
378
+ def pttl(key)
379
+ run(:PTTL, key)
380
+ end
381
+
382
+ # Return a random key from the keyspace
383
+ # @see http://redis.io/commands/randomkey
384
+ #
385
+ # @return [String] the random key
386
+ # @return [nil] if database is empty
387
+ def randomkey
388
+ run(:RANDOMKEY)
389
+ end
390
+
391
+ # Rename a key
392
+ # @see http://redis.io/commands/rename
393
+ #
394
+ # @param [String] key to rename
395
+ # @param [String] newkey
396
+ #
397
+ # @return [String] OK in case of success
398
+ # @return [RError] if key does not exist. Before Redis 3.2.0, an error is
399
+ # returned if source and destination names are the same.
400
+ def rename(key, newkey)
401
+ run(:RENAME, key, newkey)
402
+ end
403
+
404
+ # Rename a key, only if the new key does not exist
405
+ # @see http://redis.io/commands/renamenx
406
+ #
407
+ # @param [String] key to rename
408
+ # @param [String] newkey
409
+ #
410
+ # @return [Integer] 1 if key was renamed to newkey. 0 if newkey already
411
+ # exists.
412
+ # @return [RError] if key does not exist. Before Redis 3.2.0, an error is
413
+ # returned if source and destination names are the same.
414
+ def renamenx(key, newkey)
415
+ run(:RENAMENX, key, newkey)
416
+ end
417
+
418
+ # Create a key using the provided serialized value, previously obtained
419
+ # using DUMP
420
+ # @see http://redis.io/commands/restore
421
+ #
422
+ # @param [String] key
423
+ # @param [Integer] ttl expire time in milliseconds
424
+ # @param [String] serialized_value obtained using DUMP command
425
+ # @param [Hash] opts
426
+ #
427
+ # @option opts [Boolean] :replace (false) Override key if it already exists
428
+ #
429
+ # @return [String] OK on success
430
+ # @return [RError] if replace is false and key already exists or RDB version
431
+ # and data checksum don't match.
432
+ def restore(key, ttl, serialized_value, opts = {})
433
+ args = [:RESTORE, key, ttl, serialized_value]
434
+ args << :REPLACE if opts[:replace]
435
+
436
+ run(*args)
437
+ end
438
+
439
+ # Get the time to live for a key
440
+ # @see http://redis.io/commands/ttl
441
+ #
442
+ # @param [String] key
443
+ #
444
+ # @return [Integer] TTL in seconds, or a negative value in order to signal
445
+ # an error
446
+ def ttl(key)
447
+ run(:TTL, key)
448
+ end
449
+
450
+ # Determine the type stored at key
451
+ # @see http://redis.io/commands/type
452
+ #
453
+ # @param [String] key
454
+ #
455
+ # @return [String] type of key, or none when key does not exist.
456
+ def type(key)
457
+ run(:TYPE, key)
458
+ end
459
+
282
460
  # ------------------ Sets ------------------------
283
461
 
284
462
  # Add one or more members to a set
@@ -326,10 +504,24 @@ module Oxblood
326
504
  # @param [String] key under which set is stored
327
505
  # @param [String] min value
328
506
  # @param [String] max value
507
+ #
508
+ # @return [Array] list of elements in the specified score range
329
509
  def zrangebyscore(key, min, max)
330
510
  run(:ZRANGEBYSCORE, key, min, max)
331
511
  end
332
512
 
513
+ # Remove one or more members from a sorted set
514
+ # @see http://redis.io/commands/zrem
515
+ #
516
+ # @param [String] key
517
+ # @param [Array<String>] members to delete
518
+ #
519
+ # @return [Integer] number of deleted members
520
+ # @return [RError] when key exists and does not hold a sorted set.
521
+ def zrem(key, *members)
522
+ run(*members.unshift(:ZREM, key))
523
+ end
524
+
333
525
  protected
334
526
 
335
527
  def serialize(*command)
@@ -1,3 +1,3 @@
1
1
  module Oxblood
2
- VERSION = '0.1.0.dev5'
2
+ VERSION = '0.1.0.dev6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxblood
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.dev5
4
+ version: 0.1.0.dev6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Shabanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-04 00:00:00.000000000 Z
11
+ date: 2016-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: 1.3.1
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.5.1
146
+ rubygems_version: 2.6.6
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: A Ruby Redis client