picky 4.12.11 → 4.12.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -233,28 +233,18 @@ module Picky
233
233
  #
234
234
  begin
235
235
  if identifiers.size > 1
236
- if @ids_script_hash
237
- # Reuse script already installed in Redis.
238
- #
239
- client.evalsha @ids_script_hash,
240
- identifiers,
241
- [
242
- generate_intermediate_result_id,
243
- offset,
244
- (offset + amount)
245
- ]
246
- else
247
- # Install script in Redis.
248
- #
249
- @ids_script_hash = Digest::SHA1.hexdigest @ids_script
250
- client.eval @ids_script,
251
- identifiers,
252
- [
253
- generate_intermediate_result_id,
254
- offset,
255
- (offset + amount)
256
- ]
257
- end
236
+ # Reuse script already installed in Redis.
237
+ #
238
+ # Note: This may raise an error in Redis,
239
+ # when the script is not installed.
240
+ #
241
+ client.evalsha @ids_script_hash,
242
+ identifiers,
243
+ [
244
+ generate_intermediate_result_id,
245
+ offset,
246
+ (offset + amount)
247
+ ]
258
248
  else
259
249
  # No complex calculation necessary.
260
250
  #
@@ -262,6 +252,19 @@ module Picky
262
252
  offset,
263
253
  (offset + amount)
264
254
  end
255
+ rescue RuntimeError => e # Redis::CommandError
256
+ # Install script in Redis.
257
+ #
258
+ # TODO Use SCRIPT LOAD, then retry?
259
+ #
260
+ @ids_script_hash = Digest::SHA1.hexdigest @ids_script
261
+ client.eval @ids_script,
262
+ identifiers,
263
+ [
264
+ generate_intermediate_result_id,
265
+ offset,
266
+ (offset + amount)
267
+ ]
265
268
  end
266
269
  end
267
270
  end
@@ -507,6 +507,16 @@ describe "Realtime Indexing" do
507
507
 
508
508
  books.search('author:author title:Titl').ids.should == ['one']
509
509
  end
510
+
511
+ it 'finds the first entry the second time, even if the Redis script cache is flushed' do
512
+ books.search('author:author title:Titl')
513
+
514
+ books.search('author:author title:Titl').ids.should == ['one']
515
+
516
+ index.backend.client.script 'flush'
517
+
518
+ books.search('author:author title:Titl').ids.should == ['one']
519
+ end
510
520
 
511
521
  it 'allows removing a single category and leaving the others alone' do
512
522
  index[:title].remove 'one'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.11
4
+ version: 4.12.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 4.12.11
37
+ version: 4.12.12
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 4.12.11
45
+ version: 4.12.12
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: text
48
48
  requirement: !ruby/object:Gem::Requirement