ffi-hiredis_vip 0.1.0.pre1 → 0.1.0.pre2

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: ab0b43e5fa778ab53945a79ccb56a3680a845aca
4
- data.tar.gz: 13ed771c3c8b05b3d0686318c0bd58178db315a3
3
+ metadata.gz: 5d392a1b85f1385b7d1d85dec53a4b53b11bdde7
4
+ data.tar.gz: 49d262af8f46e4393a60671eadf411bcc9f8652f
5
5
  SHA512:
6
- metadata.gz: 852d415b1fbee1e6300c10aecd57ef7f04ea45e7e5a03fa70250e96f2372072d9c1cd2dda8e0d19393b7f61316f13974ede5838d9a727c116bf2ef3376e8ea16
7
- data.tar.gz: d9868b4248f0f8f1c8e7b6b18d54ae875855a2f3640dfd3d00cecf423f11ee54b759c4d03927b7a02ee85a18795c5785d2e36758f12aff47336c14d2dd424f55
6
+ metadata.gz: a07d40b8d3c9cb72483b4fc09e74c6b07752a2d2a63241882c127e6eb142d71594fdde229798fcfc8479ac674c4e5e747e8090ef8c098a202cf81c9d50f2a0e2
7
+ data.tar.gz: 4d3da8146e51139744964f25c964099836977f9ed0d214edf369c003b2526cbfc10711aa802ab7ea0766eca878952a9365f3940dd4c85934b75e54a0b86a68f4
@@ -50,10 +50,14 @@ module FFI
50
50
  mon_synchronize { yield(@connection) }
51
51
  end
52
52
 
53
+ def execute_command(*args)
54
+ ::FFI::HiredisVip::Core.command(*args)
55
+ end
56
+
53
57
  def dbsize
54
58
  reply = nil
55
59
  synchronize do |connection|
56
- reply = ::FFI::HiredisVip::Core.command(connection, "DBSIZE")
60
+ reply = execute_command(connection, "DBSIZE")
57
61
  end
58
62
 
59
63
  case reply[:type]
@@ -69,7 +73,7 @@ module FFI
69
73
  command = "DECR %b"
70
74
  command_args = [ :string, key, :size_t, key.size ]
71
75
  synchronize do |connection|
72
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
76
+ reply = execute_command(connection, command, *command_args)
73
77
  end
74
78
 
75
79
  return nil if reply.nil? || reply.null?
@@ -88,7 +92,7 @@ module FFI
88
92
  command = "DECRBY %b %b"
89
93
  command_args = [ :string, key, :size_t, key.size, :string, _amount, :size_t, _amount.size ]
90
94
  synchronize do |connection|
91
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
95
+ reply = execute_command(connection, command, *command_args)
92
96
  end
93
97
 
94
98
  return nil if reply.nil? || reply.null?
@@ -112,7 +116,7 @@ module FFI
112
116
  end
113
117
 
114
118
  synchronize do |connection|
115
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
119
+ reply = execute_command(connection, command, *command_args)
116
120
  end
117
121
 
118
122
  return nil if reply.nil? || reply.null?
@@ -130,7 +134,7 @@ module FFI
130
134
  command = "DUMP %b"
131
135
  command_args = [ :string, key, :size_t, key.size ]
132
136
  synchronize do |connection|
133
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
137
+ reply = execute_command(connection, command, *command_args)
134
138
  end
135
139
 
136
140
  return nil if reply.nil? || reply.null?
@@ -148,7 +152,7 @@ module FFI
148
152
  command = "ECHO %b"
149
153
  command_args = [ :string, value, :size_t, value.size ]
150
154
  synchronize do |connection|
151
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
155
+ reply = execute_command(connection, command, *command_args)
152
156
  end
153
157
 
154
158
  return nil if reply.nil? || reply.null?
@@ -181,7 +185,7 @@ module FFI
181
185
  command = "EXPIRE %b %b"
182
186
  command_args = [ :string, key, :size_t, key.size, :string, time_in_seconds, :size_t, time_in_seconds.size ]
183
187
  synchronize do |connection|
184
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
188
+ reply = execute_command(connection, command, *command_args)
185
189
  end
186
190
 
187
191
  # TODO: should we return a 0 here?
@@ -205,7 +209,7 @@ module FFI
205
209
  command = "EXPIREAT %b %b"
206
210
  command_args = [ :string, key, :size_t, key.size, :string, epoch, :size_t, epoch.size ]
207
211
  synchronize do |connection|
208
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
212
+ reply = execute_command(connection, command, *command_args)
209
213
  end
210
214
 
211
215
  return 0 if reply.nil? || reply.null?
@@ -225,7 +229,7 @@ module FFI
225
229
  def flushall
226
230
  reply = nil
227
231
  synchronize do |connection|
228
- reply = ::FFI::HiredisVip::Core.command(connection, "FLUSHALL")
232
+ reply = execute_command(connection, "FLUSHALL")
229
233
  end
230
234
 
231
235
  return "" if reply.nil? || reply.null?
@@ -245,7 +249,7 @@ module FFI
245
249
  def flushdb
246
250
  reply = nil
247
251
  synchronize do |connection|
248
- reply = ::FFI::HiredisVip::Core.command(connection, "FLUSHDB")
252
+ reply = execute_command(connection, "FLUSHDB")
249
253
  end
250
254
 
251
255
  return "" if reply.nil? || reply.null?
@@ -268,7 +272,7 @@ module FFI
268
272
  command_args = [ :string, key, :size_t, key.size ]
269
273
 
270
274
  synchronize do |connection|
271
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
275
+ reply = execute_command(connection, command, *command_args)
272
276
  end
273
277
 
274
278
  return nil if reply.nil? || reply.null?
@@ -289,7 +293,7 @@ module FFI
289
293
  command = "INCR %b"
290
294
  command_args = [ :string, key, :size_t, key.size ]
291
295
  synchronize do |connection|
292
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
296
+ reply = execute_command(connection, command, *command_args)
293
297
  end
294
298
 
295
299
  return nil if reply.nil? || reply.null?
@@ -308,7 +312,7 @@ module FFI
308
312
  command = "INCRBY %b %b"
309
313
  command_args = [ :string, key, :size_t, key.size, :string, _amount, :size_t, _amount.size ]
310
314
  synchronize do |connection|
311
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
315
+ reply = execute_command(connection, command, *command_args)
312
316
  end
313
317
 
314
318
  return nil if reply.nil? || reply.null?
@@ -324,7 +328,7 @@ module FFI
324
328
  def info
325
329
  reply = nil
326
330
  synchronize do |connection|
327
- reply = ::FFI::HiredisVip::Core.command(connection, "INFO")
331
+ reply = execute_command(connection, "INFO")
328
332
  end
329
333
 
330
334
  return "" if reply.nil? || reply.null?
@@ -358,7 +362,7 @@ module FFI
358
362
  def ping
359
363
  reply = nil
360
364
  synchronize do |connection|
361
- reply = ::FFI::HiredisVip::Core.command(connection, "PING")
365
+ reply = execute_command(connection, "PING")
362
366
  end
363
367
 
364
368
  return nil if reply.nil? || reply.null?
@@ -435,7 +439,7 @@ module FFI
435
439
  command = "SELECT %b"
436
440
  command_args = [ :string, db, :size_t, db.size ]
437
441
  synchronize do |connection|
438
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
442
+ reply = execute_command(connection, command, *command_args)
439
443
  end
440
444
 
441
445
  return nil if reply.nil? || reply.null?
@@ -498,7 +502,7 @@ module FFI
498
502
  command = "TTL %b"
499
503
  command_args = [ :string, key, :size_t, key.size ]
500
504
  synchronize do |connection|
501
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
505
+ reply = execute_command(connection, command, *command_args)
502
506
  end
503
507
 
504
508
  return nil if reply.nil? || reply.null?
@@ -15,8 +15,8 @@ module FFI
15
15
  command_args << :string << key << :size_t << key.size
16
16
  end
17
17
 
18
- @client.synchronize do |connection|
19
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
18
+ synchronize do |connection|
19
+ reply = @client.execute_command(connection, command, *command_args)
20
20
  end
21
21
 
22
22
  return nil if reply.nil? || reply.null?
@@ -28,6 +28,15 @@ module FFI
28
28
  0
29
29
  end
30
30
  end
31
+
32
+ private
33
+
34
+ def synchronize
35
+ @client.synchronize do |connection|
36
+ yield(connection)
37
+ end
38
+ end
39
+
31
40
  end # class Exists
32
41
  end # module HiredisVip
33
42
  end # module FFI
@@ -14,7 +14,7 @@ module FFI
14
14
  reply = nil
15
15
  command_args = [ :string, key, :size_t, key.size ]
16
16
  @client.synchronize do |connection|
17
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
17
+ reply = @client.execute_command(connection, command, *command_args)
18
18
  end
19
19
 
20
20
  next if reply.nil? || reply.null?
@@ -12,7 +12,7 @@ module FFI
12
12
  command_args = [ :string, pattern, :size_t, pattern.size ]
13
13
 
14
14
  synchronize do |connection|
15
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
15
+ reply = @client.execute_command(connection, command, *command_args)
16
16
  end
17
17
 
18
18
  return nil if reply.nil? || reply.null?
@@ -16,7 +16,7 @@ module FFI
16
16
  end
17
17
 
18
18
  synchronize do |connection|
19
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
19
+ reply = @client.execute_command(connection, command, *command_args)
20
20
  end
21
21
 
22
22
  return nil if reply.nil? || reply.null?
@@ -10,7 +10,7 @@ module FFI
10
10
  command = "PERSIST %b"
11
11
  command_args = [ :string, key, :size_t, key.size ]
12
12
  synchronize do |connection|
13
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
13
+ reply = @client.execute_command(connection, command, *command_args)
14
14
  end
15
15
 
16
16
  return nil if reply.nil? || reply.null?
@@ -16,7 +16,7 @@ module FFI
16
16
  end
17
17
 
18
18
  synchronize do |connection|
19
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
19
+ reply = @client.execute_command(connection, command, *command_args)
20
20
  end
21
21
 
22
22
  return nil if reply.nil? || reply.null?
@@ -13,7 +13,7 @@ module FFI
13
13
  values.each do |value|
14
14
  command_args = [ :string, key, :size_t, key.size, :string, value, :size_t, value.size ]
15
15
  synchronize do |connection|
16
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
16
+ reply = @client.execute_command(connection, command, *command_args)
17
17
 
18
18
  next if reply.nil? || reply.null?
19
19
 
@@ -23,7 +23,7 @@ module FFI
23
23
  end
24
24
 
25
25
  synchronize do |connection|
26
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
26
+ reply = @client.execute_command(connection, command, *command_args)
27
27
  end
28
28
 
29
29
  return nil if reply.nil?
@@ -12,6 +12,7 @@ module FFI
12
12
  def set(key, value, options = {})
13
13
  reply = nil
14
14
  command = "SET %b %b"
15
+ value = value.to_s
15
16
  command_args = [ :string, key, :size_t, key.size, :string, value, :size_t, value.size ]
16
17
 
17
18
  if options[:ex]
@@ -30,7 +31,7 @@ module FFI
30
31
  command << " XX" if options[:xx]
31
32
 
32
33
  synchronize do |connection|
33
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
34
+ reply = @client.execute_command(connection, command, *command_args)
34
35
  end
35
36
 
36
37
  return nil if reply.nil? || reply.null?
@@ -8,11 +8,12 @@ module FFI
8
8
  def psetex(key, value, expiry)
9
9
  expiry = "#{expiry}"
10
10
  reply = nil
11
+ value = value.to_s
11
12
  command = "PSETEX %b %b %b"
12
13
  command_args = [ :string, key, :size_t, key.size, :string, expiry, :size_t, expiry.size, :string, value, :size_t, value.size ]
13
14
 
14
15
  synchronize do |connection|
15
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
16
+ reply = @client.execute_command(connection, command, *command_args)
16
17
  end
17
18
 
18
19
  return nil if reply.nil? || reply.null?
@@ -31,6 +32,7 @@ module FFI
31
32
 
32
33
  def set(key, value, options = {})
33
34
  reply = nil
35
+ value = value.to_s
34
36
  command = "SET %b %b"
35
37
  command_args = [ :string, key, :size_t, key.size, :string, value, :size_t, value.size ]
36
38
 
@@ -44,7 +46,7 @@ module FFI
44
46
  end
45
47
 
46
48
  synchronize do |connection|
47
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
49
+ reply = @client.execute_command(connection, command, *command_args)
48
50
  end
49
51
 
50
52
  return nil if reply.nil? || reply.null?
@@ -64,11 +66,12 @@ module FFI
64
66
  def setex(key, value, expiry)
65
67
  expiry = "#{expiry}"
66
68
  reply = nil
69
+ value = value.to_s
67
70
  command = "SETEX %b %b %b"
68
71
  command_args = [ :string, key, :size_t, key.size, :string, expiry, :size_t, expiry.size, :string, value, :size_t, value.size ]
69
72
 
70
73
  synchronize do |connection|
71
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
74
+ reply = @client.execute_command(connection, command, *command_args)
72
75
  end
73
76
 
74
77
  return nil if reply.nil? || reply.null?
@@ -87,11 +90,12 @@ module FFI
87
90
 
88
91
  def setnx(key, value)
89
92
  reply = nil
93
+ value = value.to_s
90
94
  command = "SETNX %b %b"
91
95
  command_args = [ :string, key, :size_t, key.size, :string, value, :size_t, value.size ]
92
96
 
93
97
  synchronize do |connection|
94
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
98
+ reply = @client.execute_command(connection, command, *command_args)
95
99
  end
96
100
 
97
101
  return nil if reply.nil? || reply.null?
@@ -23,7 +23,7 @@ module FFI
23
23
  end
24
24
 
25
25
  synchronize do |connection|
26
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
26
+ reply = @client.execute_command(connection, command, *command_args)
27
27
  end
28
28
 
29
29
  return nil if reply.nil? || reply.null?
@@ -16,7 +16,7 @@ module FFI
16
16
  end
17
17
 
18
18
  synchronize do |connection|
19
- reply = ::FFI::HiredisVip::Core.command(connection, command, *command_args)
19
+ reply = @client.execute_command(connection, command, *command_args)
20
20
  end
21
21
 
22
22
  return nil if reply.nil? || reply.null?
@@ -1,5 +1,5 @@
1
1
  module FFI
2
2
  module HiredisVip
3
- VERSION = "0.1.0.pre1"
3
+ VERSION = "0.1.0.pre2"
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.pre1
4
+ version: 0.1.0.pre2
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-10-28 00:00:00.000000000 Z
11
+ date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi