ffi-hiredis_vip 0.1.0.pre3 → 0.1.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ead994de23fa7de4efacb74af787d989acb82d4
4
- data.tar.gz: 2e6f99f82a141bf37eb144bb57e7c1108ebd45cd
3
+ metadata.gz: 2af5809ea84ed3b06922219ab9196ed6f1939f94
4
+ data.tar.gz: 2a170e0ebc97887ab916899d06353498e4b83c5f
5
5
  SHA512:
6
- metadata.gz: efb2b833917327f59abcec80d43908eaba3fee6f113078076e0375e6fee997aef9b955975f2c95a48464e562851976818417734653da3a6036ff04c9ed70b694
7
- data.tar.gz: 2a35ee601a6d641b0633664e36c8247841137982c6f56955319509f37edcf5e313c1f2194ddfe8e3d08411c7b75cbaaa98a71ecb4195dbb569545c6c7bdd175e
6
+ metadata.gz: 37dc2641a645c099efb56f9d8c6a7baf6f91cc83fed7d73c5e1919405f99b951694058ef80d8d6a79640e538e14e3040881994870df05394aaea739bcea96142
7
+ data.tar.gz: c77ee8bbe4577b2b0f1407711622e65ffa8f4655bf5fd9a354675ef85adc82de78232c7cf8f9d02f441f95e3cec0f695883fe01a7eb8b232575d2e1a806ca5eb
@@ -66,6 +66,8 @@ module FFI
66
66
  else
67
67
  0
68
68
  end
69
+ ensure
70
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
69
71
  end
70
72
 
71
73
  def decr(key)
@@ -84,6 +86,8 @@ module FFI
84
86
  else
85
87
  0
86
88
  end
89
+ ensure
90
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
87
91
  end
88
92
 
89
93
  def decrby(key, amount)
@@ -103,6 +107,8 @@ module FFI
103
107
  else
104
108
  0
105
109
  end
110
+ ensure
111
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
106
112
  end
107
113
 
108
114
  def del(*keys)
@@ -127,6 +133,8 @@ module FFI
127
133
  else
128
134
  0
129
135
  end
136
+ ensure
137
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
130
138
  end
131
139
 
132
140
  def dump(key)
@@ -141,10 +149,12 @@ module FFI
141
149
 
142
150
  case reply[:type]
143
151
  when :REDIS_REPLY_STRING
144
- reply[:str]
152
+ reply[:str].dup
145
153
  else
146
154
  nil
147
155
  end
156
+ ensure
157
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
148
158
  end
149
159
 
150
160
  def echo(value)
@@ -159,12 +169,14 @@ module FFI
159
169
 
160
170
  case reply[:type]
161
171
  when :REDIS_REPLY_STRING
162
- reply[:str]
172
+ reply[:str].dup
163
173
  when :REDIS_REPLY_NIL
164
174
  nil
165
175
  else
166
176
  nil
167
177
  end
178
+ ensure
179
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
168
180
  end
169
181
 
170
182
  def echo?(value)
@@ -197,6 +209,8 @@ module FFI
197
209
  else
198
210
  0
199
211
  end
212
+ ensure
213
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
200
214
  end
201
215
 
202
216
  def expire?(key, seconds)
@@ -220,6 +234,8 @@ module FFI
220
234
  else
221
235
  0
222
236
  end
237
+ ensure
238
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
223
239
  end
224
240
 
225
241
  def expireat?(key, unix_time)
@@ -236,10 +252,12 @@ module FFI
236
252
 
237
253
  case reply[:type]
238
254
  when :REDIS_REPLY_STRING
239
- reply[:str]
255
+ reply[:str].dup
240
256
  else
241
257
  ""
242
258
  end
259
+ ensure
260
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
243
261
  end
244
262
 
245
263
  def flushall?
@@ -256,10 +274,12 @@ module FFI
256
274
 
257
275
  case reply[:type]
258
276
  when :REDIS_REPLY_STRING
259
- reply[:str]
277
+ reply[:str].dup
260
278
  else
261
279
  ""
262
280
  end
281
+ ensure
282
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
263
283
  end
264
284
 
265
285
  def flushdb?
@@ -279,12 +299,14 @@ module FFI
279
299
 
280
300
  case reply[:type]
281
301
  when :REDIS_REPLY_STRING
282
- reply[:str]
302
+ reply[:str].dup
283
303
  when :REDIS_REPLY_NIL
284
304
  nil
285
305
  else
286
306
  nil # TODO: should this be empty string?
287
307
  end
308
+ ensure
309
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
288
310
  end
289
311
  alias_method :[], :get
290
312
 
@@ -304,6 +326,8 @@ module FFI
304
326
  else
305
327
  0
306
328
  end
329
+ ensure
330
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
307
331
  end
308
332
 
309
333
  def incrby(key, amount)
@@ -323,6 +347,8 @@ module FFI
323
347
  else
324
348
  0
325
349
  end
350
+ ensure
351
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
326
352
  end
327
353
 
328
354
  def info
@@ -335,10 +361,12 @@ module FFI
335
361
 
336
362
  case reply[:type]
337
363
  when :REDIS_REPLY_STRING
338
- reply[:str]
364
+ reply[:str].dup
339
365
  else
340
366
  ""
341
367
  end
368
+ ensure
369
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
342
370
  end
343
371
 
344
372
  def keys(pattern)
@@ -369,12 +397,14 @@ module FFI
369
397
 
370
398
  case reply[:type]
371
399
  when :REDIS_REPLY_STATUS
372
- reply[:str]
400
+ reply[:str].dup
373
401
  when :REDIS_REPLY_STRING
374
- reply[:str]
402
+ reply[:str].dup
375
403
  else
376
404
  ""
377
405
  end
406
+ ensure
407
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
378
408
  end
379
409
 
380
410
  def ping?
@@ -397,6 +427,8 @@ module FFI
397
427
  else
398
428
  false
399
429
  end
430
+ ensure
431
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
400
432
  end
401
433
 
402
434
  def sadd(key, *values)
@@ -446,10 +478,12 @@ module FFI
446
478
 
447
479
  case reply[:type]
448
480
  when :REDIS_REPLY_STATUS
449
- reply[:str]
481
+ reply[:str].dup
450
482
  else
451
483
  nil
452
484
  end
485
+ ensure
486
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
453
487
  end
454
488
 
455
489
  def select?(db)
@@ -511,6 +545,8 @@ module FFI
511
545
  when :REDIS_REPLY_INTEGER
512
546
  reply[:integer]
513
547
  end
548
+ ensure
549
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
514
550
  end
515
551
 
516
552
  def touch(*keys)
@@ -27,6 +27,8 @@ module FFI
27
27
  else
28
28
  0
29
29
  end
30
+ ensure
31
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
30
32
  end
31
33
 
32
34
  private
@@ -11,17 +11,21 @@ module FFI
11
11
  command = "EXISTS %b"
12
12
 
13
13
  keys.each do |key|
14
- reply = nil
15
- command_args = [ :pointer, key, :size_t, key.size ]
16
- @client.synchronize do |connection|
17
- reply = @client.execute_command(connection, command, *command_args)
18
- end
14
+ begin
15
+ reply = nil
16
+ command_args = [ :pointer, key, :size_t, key.size ]
17
+ @client.synchronize do |connection|
18
+ reply = @client.execute_command(connection, command, *command_args)
19
+ end
19
20
 
20
- next if reply.nil? || reply.null?
21
+ next if reply.nil? || reply.null?
21
22
 
22
- case reply[:type]
23
- when :REDIS_REPLY_INTEGER
24
- number_of_exists = number_of_exists + reply[:integer]
23
+ case reply[:type]
24
+ when :REDIS_REPLY_INTEGER
25
+ number_of_exists = number_of_exists + reply[:integer]
26
+ end
27
+ ensure
28
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
25
29
  end
26
30
  end
27
31
 
@@ -24,6 +24,8 @@ module FFI
24
24
  else
25
25
  []
26
26
  end
27
+ ensure
28
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
27
29
  end
28
30
 
29
31
  private
@@ -36,7 +38,7 @@ module FFI
36
38
 
37
39
  case result[:type]
38
40
  when :REDIS_REPLY_STRING
39
- keys_results << result[:str]
41
+ keys_results << result[:str].dup
40
42
  end
41
43
  end
42
44
 
@@ -28,6 +28,8 @@ module FFI
28
28
  else
29
29
  []
30
30
  end
31
+ ensure
32
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
31
33
  end
32
34
 
33
35
  private
@@ -40,7 +42,7 @@ module FFI
40
42
 
41
43
  case result[:type]
42
44
  when :REDIS_REPLY_STRING
43
- mget_results << result[:str]
45
+ mget_results << result[:str].dup
44
46
  when :REDIS_REPLY_NIL
45
47
  mget_results << nil
46
48
  end
@@ -19,6 +19,8 @@ module FFI
19
19
  when :REDIS_REPLY_INTEGER
20
20
  reply[:integer]
21
21
  end
22
+ ensure
23
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
22
24
  end
23
25
 
24
26
  def supports_persist?
@@ -12,6 +12,7 @@ module FFI
12
12
  command = "SADD %b#{' %b' * number_of_values}"
13
13
  command_args = [ :pointer, key, :size_t, key.size ]
14
14
  values.each do |value|
15
+ value = value.to_s
15
16
  command_args << :pointer << value << :size_t << value.size
16
17
  end
17
18
 
@@ -27,6 +28,8 @@ module FFI
27
28
  else
28
29
  0
29
30
  end
31
+ ensure
32
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
30
33
  end
31
34
 
32
35
  private
@@ -11,16 +11,22 @@ module FFI
11
11
  command = "SADD %b %b"
12
12
 
13
13
  values.each do |value|
14
- command_args = [ :string, key, :size_t, key.size, :string, value, :size_t, value.size ]
15
- synchronize do |connection|
16
- reply = @client.execute_command(connection, command, *command_args)
17
-
18
- next if reply.nil? || reply.null?
19
-
20
- case reply[:type]
21
- when :REDIS_REPLY_INTEGER
22
- number_added_to_set = number_added_to_set + reply[:integer]
14
+ begin
15
+ reply = nil
16
+ value = value.to_s
17
+ command_args = [ :pointer, key, :size_t, key.size, :pointer, value, :size_t, value.size ]
18
+ synchronize do |connection|
19
+ reply = @client.execute_command(connection, command, *command_args)
20
+
21
+ next if reply.nil? || reply.null?
22
+
23
+ case reply[:type]
24
+ when :REDIS_REPLY_INTEGER
25
+ number_added_to_set = number_added_to_set + reply[:integer]
26
+ end
23
27
  end
28
+ ensure
29
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
24
30
  end
25
31
  end
26
32
 
@@ -33,6 +33,8 @@ module FFI
33
33
  when :REDIS_REPLY_ARRAY
34
34
  [ scan_results_cursor(reply), scan_results_to_array(reply) ]
35
35
  end
36
+ ensure
37
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
36
38
  end
37
39
 
38
40
  def supports_scan?
@@ -45,7 +47,7 @@ module FFI
45
47
  zeroth_result = ::FFI::HiredisVip::Core.redisReplyElement(reply, 0)
46
48
 
47
49
  if !zeroth_result.null? && zeroth_result[:type] == :REDIS_REPLY_STRING
48
- zeroth_result[:str]
50
+ zeroth_result[:str].dup
49
51
  else
50
52
  raise "probs" # TODO: what do we do here
51
53
  end
@@ -58,7 +60,7 @@ module FFI
58
60
  if !array_reply.null? && array_reply[:type] == :REDIS_REPLY_ARRAY
59
61
  0.upto(array_reply[:elements] - 1) do |element_number|
60
62
  result = ::FFI::HiredisVip::Core.redisReplyElement(array_reply, element_number)
61
- scan_results << result[:str] if result[:type] == :REDIS_REPLY_STRING
63
+ scan_results << result[:str].dup if result[:type] == :REDIS_REPLY_STRING
62
64
  end
63
65
 
64
66
  scan_results
@@ -38,14 +38,16 @@ module FFI
38
38
 
39
39
  case reply[:type]
40
40
  when :REDIS_REPLY_STRING
41
- reply[:str]
41
+ reply[:str].dup
42
42
  when :REDIS_REPLY_STATUS
43
- reply[:str]
43
+ reply[:str].dup
44
44
  when :REDIS_REPLY_NIL
45
45
  nil
46
46
  else
47
47
  ""
48
48
  end
49
+ ensure
50
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
49
51
  end
50
52
 
51
53
  def setex(key, value, expiry)
@@ -20,14 +20,16 @@ module FFI
20
20
 
21
21
  case reply[:type]
22
22
  when :REDIS_REPLY_STRING
23
- reply[:str]
23
+ reply[:str].dup
24
24
  when :REDIS_REPLY_STATUS
25
- reply[:str]
25
+ reply[:str].dup
26
26
  when :REDIS_REPLY_NIL
27
27
  nil
28
28
  else
29
29
  ""
30
30
  end
31
+ ensure
32
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
31
33
  end
32
34
 
33
35
  def set(key, value, options = {})
@@ -53,14 +55,16 @@ module FFI
53
55
 
54
56
  case reply[:type]
55
57
  when :REDIS_REPLY_STRING
56
- reply[:str]
58
+ reply[:str].dup
57
59
  when :REDIS_REPLY_STATUS
58
- reply[:str]
60
+ reply[:str].dup
59
61
  when :REDIS_REPLY_NIL
60
62
  nil
61
63
  else
62
64
  ""
63
65
  end
66
+ ensure
67
+ ::FFI::HiredisVip::Core.freeReplyObject(reply) if reply
64
68
  end
65
69
 
66
70
  def setex(key, value, expiry)
@@ -78,14 +82,16 @@ module FFI
78
82
 
79
83
  case reply[:type]
80
84
  when :REDIS_REPLY_STRING
81
- reply[:str]
85
+ reply[:str].dup
82
86
  when :REDIS_REPLY_STATUS
83
- reply[:str]
87
+ reply[:str].dup
84
88
  when :REDIS_REPLY_NIL
85
89
  nil
86
90
  else
87
91
  ""
88
92
  end
93
+ ensure
94
+ ::FFI::HiredisVip::Core.freeReplyObject(reply) if reply
89
95
  end
90
96
 
91
97
  def setnx(key, value)
@@ -102,14 +108,16 @@ module FFI
102
108
 
103
109
  case reply[:type]
104
110
  when :REDIS_REPLY_STRING
105
- reply[:str]
111
+ reply[:str].dup
106
112
  when :REDIS_REPLY_STATUS
107
- reply[:str]
113
+ reply[:str].dup
108
114
  when :REDIS_REPLY_NIL
109
115
  nil
110
116
  else
111
117
  ""
112
118
  end
119
+ ensure
120
+ ::FFI::HiredisVip::Core.freeReplyObject(reply) if reply
113
121
  end
114
122
 
115
123
  private
@@ -33,6 +33,8 @@ module FFI
33
33
  when :REDIS_REPLY_ARRAY
34
34
  [ scan_results_cursor(reply), scan_results_to_array(reply) ]
35
35
  end
36
+ ensure
37
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
36
38
  end
37
39
 
38
40
  def supports_sscan?
@@ -45,7 +47,7 @@ module FFI
45
47
  zeroth_result = ::FFI::HiredisVip::Core.redisReplyElement(reply, 0)
46
48
 
47
49
  if !zeroth_result.null? && zeroth_result[:type] == :REDIS_REPLY_STRING
48
- zeroth_result[:str]
50
+ zeroth_result[:str].dup
49
51
  else
50
52
  raise "probs" # TODO: what do we do here
51
53
  end
@@ -58,7 +60,7 @@ module FFI
58
60
  if !array_reply.null? && array_reply[:type] == :REDIS_REPLY_ARRAY
59
61
  0.upto(array_reply[:elements] - 1) do |element_number|
60
62
  result = ::FFI::HiredisVip::Core.redisReplyElement(array_reply, element_number)
61
- scan_results << result[:str] if result[:type] == :REDIS_REPLY_STRING
63
+ scan_results << result[:str].dup if result[:type] == :REDIS_REPLY_STRING
62
64
  end
63
65
 
64
66
  scan_results
@@ -27,6 +27,8 @@ module FFI
27
27
  else
28
28
  0
29
29
  end
30
+ ensure
31
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
30
32
  end
31
33
 
32
34
  def supports_touch?
@@ -1,5 +1,5 @@
1
1
  module FFI
2
2
  module HiredisVip
3
- VERSION = "0.1.0.pre3"
3
+ VERSION = "0.1.0.pre4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-hiredis_vip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre3
4
+ version: 0.1.0.pre4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi