acts_as_hashish 0.1.0 → 0.2.0
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.
@@ -7,13 +7,15 @@ module Hashish
|
|
7
7
|
# Redis namespace for keys
|
8
8
|
attr_writer :redis_namespace
|
9
9
|
|
10
|
-
# Redis
|
10
|
+
# Redis search keys ttl (minutes)
|
11
11
|
attr_writer :redis_search_keys_ttl
|
12
12
|
|
13
|
+
# Redis namespace for keys
|
13
14
|
def redis_namespace
|
14
15
|
@redis_namespace ||= 'hashish'
|
15
16
|
end
|
16
17
|
|
18
|
+
# Redis search keys ttl (minutes)
|
17
19
|
def redis_search_keys_ttl
|
18
20
|
@redis_search_keys_ttl ||= 5 # minutes
|
19
21
|
end
|
@@ -20,7 +20,6 @@ module Hashish
|
|
20
20
|
end
|
21
21
|
|
22
22
|
public
|
23
|
-
# this needs some improvisation
|
24
23
|
def rebuild_indexes
|
25
24
|
get_list(:page_size => 0).each do |item|
|
26
25
|
hashish_insert(item)
|
@@ -65,12 +64,12 @@ module Hashish
|
|
65
64
|
end
|
66
65
|
@options[:sorters].each do |sort_field, sort|
|
67
66
|
sort_value = sort.is_a?(Proc) ? sort.call(o) : o[sort]
|
68
|
-
Hashish.redis_connection.set("#{prefix}:#{key}:#{
|
67
|
+
Hashish.redis_connection.set("#{prefix}:#{key}:#{sort_field}", sort_value)
|
69
68
|
end
|
70
69
|
Hashish.redis_connection.set("#{prefix}:#{key}", data)
|
71
70
|
true
|
72
71
|
end
|
73
|
-
|
72
|
+
|
74
73
|
def hashish_list(*args)
|
75
74
|
category = nil
|
76
75
|
|
@@ -155,7 +154,7 @@ module Hashish
|
|
155
154
|
Hashish.redis_connection.expire(custom_sort, Hashish.redis_search_keys_ttl * 60)
|
156
155
|
result = Hashish.redis_connection.lrange(custom_sort, offset, limit -1)
|
157
156
|
else
|
158
|
-
res_keys = Hashish.redis_connection.
|
157
|
+
res_keys = Hashish.redis_connection.send("z#{(sort_order == 'DESC' ? 'rev' : '')}range".to_sym, result_key, offset, limit - 1)
|
159
158
|
if res_keys.empty?
|
160
159
|
result = []
|
161
160
|
else
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: acts_as_hashish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Schubert Cardozo
|
@@ -112,3 +112,4 @@ specification_version: 3
|
|
112
112
|
summary: A sortable and searchable list backed by Redis
|
113
113
|
test_files: []
|
114
114
|
|
115
|
+
has_rdoc:
|