Class: Lowkiq::Queue::Queries

Inherits:
Object
  • Object
show all
Defined in:
lib/lowkiq/queue/queries.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis_pool, name) ⇒ Queries

Returns a new instance of Queries.



4
5
6
7
8
# File 'lib/lowkiq/queue/queries.rb', line 4

def initialize(redis_pool, name)
  @pool = redis_pool
  @keys = Keys.new name
  @fetch = Fetch.new name
end

Instance Method Details

#fetch(ids) ⇒ Object



120
121
122
123
124
# File 'lib/lowkiq/queue/queries.rb', line 120

def fetch(ids)
  @pool.with do |redis|
    _fetch redis, ids
  end
end

#morgue_fetch(ids) ⇒ Object



126
127
128
129
130
# File 'lib/lowkiq/queue/queries.rb', line 126

def morgue_fetch(ids)
  @pool.with do |redis|
    _morgue_fetch redis, ids
  end
end

#morgue_range_by_id(min, max, limit: 10) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/lowkiq/queue/queries.rb', line 76

def morgue_range_by_id(min, max, limit: 10)
  @pool.with do |redis|
    ids = redis.zrangebylex(
      @keys.morgue_all_ids_lex_zset,
      min, max,
      limit: [0, limit]
    )
    _morgue_fetch redis, ids
  end
end

#morgue_range_by_updated_at(min, max, limit: 10) ⇒ Object



98
99
100
101
102
103
104
105
106
107
# File 'lib/lowkiq/queue/queries.rb', line 98

def morgue_range_by_updated_at(min, max, limit: 10)
  @pool.with do |redis|
    ids = redis.zrangebyscore(
      @keys.morgue_all_ids_scored_by_updated_at_zset,
      min, max,
      limit: [0, limit]
    )
    _morgue_fetch redis, ids
  end
end

#morgue_rev_range_by_id(max, min, limit: 10) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/lowkiq/queue/queries.rb', line 87

def morgue_rev_range_by_id(max, min, limit: 10)
  @pool.with do |redis|
    ids = redis.zrevrangebylex(
      @keys.morgue_all_ids_lex_zset,
      max, min,
      limit: [0, limit]
    )
    _morgue_fetch redis, ids
  end
end

#morgue_rev_range_by_updated_at(max, min, limit: 10) ⇒ Object



109
110
111
112
113
114
115
116
117
118
# File 'lib/lowkiq/queue/queries.rb', line 109

def morgue_rev_range_by_updated_at(max, min, limit: 10)
  @pool.with do |redis|
    ids = redis.zrevrangebyscore(
      @keys.morgue_all_ids_scored_by_updated_at_zset,
      max, min,
      limit: [0, limit]
    )
    _morgue_fetch redis, ids
  end
end

#range_by_id(min, max, limit: 10) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/lowkiq/queue/queries.rb', line 10

def range_by_id(min, max, limit: 10)
  @pool.with do |redis|
    ids = redis.zrangebylex(
      @keys.all_ids_lex_zset,
      min, max,
      limit: [0, limit]
    )
    _fetch redis, ids
  end
end

#range_by_perform_in(min, max, limit: 10) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/lowkiq/queue/queries.rb', line 32

def range_by_perform_in(min, max, limit: 10)
  @pool.with do |redis|
    ids = redis.zrangebyscore(
      @keys.all_ids_scored_by_perform_in_zset,
      min, max,
      limit: [0, limit]
    )
    _fetch redis, ids
  end
end

#range_by_retry_count(min, max, limit: 10) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/lowkiq/queue/queries.rb', line 54

def range_by_retry_count(min, max, limit: 10)
  @pool.with do |redis|
    ids = redis.zrangebyscore(
      @keys.all_ids_scored_by_retry_count_zset,
      min, max,
      limit: [0, limit]
    )
    _fetch redis, ids
  end
end

#rev_range_by_id(max, min, limit: 10) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/lowkiq/queue/queries.rb', line 21

def rev_range_by_id(max, min, limit: 10)
  @pool.with do |redis|
    ids = redis.zrevrangebylex(
      @keys.all_ids_lex_zset,
      max, min,
      limit: [0, limit]
    )
    _fetch redis, ids
  end
end

#rev_range_by_perform_in(max, min, limit: 10) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/lowkiq/queue/queries.rb', line 43

def rev_range_by_perform_in(max, min, limit: 10)
  @pool.with do |redis|
    ids = redis.zrevrangebyscore(
      @keys.all_ids_scored_by_perform_in_zset,
      max, min,
      limit: [0, limit]
    )
    _fetch redis, ids
  end
end

#rev_range_by_retry_count(max, min, limit: 10) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/lowkiq/queue/queries.rb', line 65

def rev_range_by_retry_count(max, min, limit: 10)
  @pool.with do |redis|
    ids = redis.zrevrangebyscore(
      @keys.all_ids_scored_by_retry_count_zset,
      max, min,
      limit: [0, limit]
    )
    _fetch redis, ids
  end
end