mondrian_redis_segment_cache 0.4.3-java → 0.4.4-java

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: 88709a1d58722c160949477aa669a4dd4b44b2dc
4
- data.tar.gz: 57329e543ccd6864700b83d01e7d3df21ba4f0fb
3
+ metadata.gz: 846739c7d8f7e615e241b6f87736edb84ff6389c
4
+ data.tar.gz: b85140550855920737f35be7b6c6e0148b0d5237
5
5
  SHA512:
6
- metadata.gz: df69a5725f485e23119b0c878501a01e9bd98bacd744f972e6adc33cdb8def60b3c2ffe0693aebe20cb3b7626c8cf3b04f88788aa7fd3a2413bbea2ced7a215c
7
- data.tar.gz: c9f30fec5cd3dbd0dc7eb906dee1279eb836ae341dc86e28ebff0bc54f97ebf110f261e067c51e5329e2b2b64176defd8fce6dfc9a3fc09af89bd15f5ed7fe59
6
+ metadata.gz: e82def47c87d8f0290a45b3106696d25a00e4ade0163916f95de5b0eff15eb120062f3d9ae1eb5921a81fb27a8ec9679aba9382cf0935ad54a4dd1177990e3ae
7
+ data.tar.gz: ce194dbc0961acd5bcec1a1e3a90a859216303386074fb8bb1e5091fa6a95840d95d4e07e71734076bef034873a0018db73d35865c0439ebe189326f0a4b0e7a
@@ -104,8 +104,33 @@ module MondrianRedisSegmentCache
104
104
  end
105
105
 
106
106
  def reload
107
- reconcile_set_and_keys
108
- reconcile_local_set_with_redis
107
+ existing_hash_vals = ::Set.new
108
+
109
+ mondrian_redis.with do |connection|
110
+ connection.sscan_each(SEGMENT_HEADERS_SET_KEY) do |segment_header_base64|
111
+ unless connection.exists(segment_header_base64)
112
+ connection.srem(SEGMENT_HEADERS_SET_KEY, segment_header_base64)
113
+ next
114
+ end
115
+
116
+ existing_hash_vals << segment_header_base64.hash
117
+
118
+ unless local_cache_set.include?(segment_header_base64)
119
+ @local_cache_set << segment_header_base64
120
+ publish_created_to_listeners(segment_header_base64)
121
+ end
122
+ end
123
+ end
124
+
125
+ local_cache_set.select! do |segment|
126
+ unless existing_hash_vals.include?(segment.hash)
127
+ publish_deleted_to_listeners(segment)
128
+ end
129
+
130
+ existing_hash_vals.include?(segment.hash)
131
+ end
132
+
133
+ true
109
134
  end
110
135
 
111
136
  def remove(segment_header)
@@ -167,7 +192,7 @@ module MondrianRedisSegmentCache
167
192
  end
168
193
 
169
194
  def has_expiry?
170
- options.has_key?(:ttl) || options.has_key?(:expires_at)
195
+ options.has_key?(:ttl) || options.has_key?(:expires_at) || options.has_key?(:expires) || options.has_key?(:expires_callback)
171
196
  end
172
197
 
173
198
  def publish_created_to_listener(message, listener)
@@ -200,49 +225,9 @@ module MondrianRedisSegmentCache
200
225
  end
201
226
  end
202
227
 
203
- def reconcile_local_set_with_redis
204
- remote_set = []
205
-
206
- mondrian_redis.with do |connection|
207
- connection.sscan_each(SEGMENT_HEADERS_SET_KEY) do |segment_header_base64|
208
- remote_set << segment_header_base64
209
- end
210
- end
211
-
212
- local_copy = []
213
- local_cache_set.each { |value| local_copy << value }
214
- remote_added_keys = remote_set - local_copy
215
- remote_removed_keys = local_copy - remote_set
216
-
217
- remote_added_keys.each do |remote_added_key|
218
- @local_cache_set << remote_added_key
219
- publish_created_to_listeners(remote_added_key)
220
- end
221
-
222
- remote_removed_keys.each do |remote_removed_key|
223
- @local_cache_set.delete(remote_removed_key)
224
- publish_deleted_to_listeners(remote_removed_key)
225
- end
226
- end
227
-
228
- def reconcile_set_and_keys
229
- headers = []
230
- mondrian_redis.with do |connection|
231
- connection.sscan_each(SEGMENT_HEADERS_SET_KEY) do |segment_header_base64|
232
- headers << segment_header_base64
233
- end
234
- end
235
-
236
- mondrian_redis.with do |connection|
237
- headers.each do |header|
238
- # Spin through Header Set and remove any keys that are not in redis at all (they may have been deleted while offline)
239
- connection.srem(SEGMENT_HEADERS_SET_KEY, header) unless connection.exists(header)
240
- end
241
- end
242
- end
243
-
244
228
  def segment_body_from_base64(segment_body_base64)
245
229
  return nil unless segment_body_base64
230
+ return nil if segment_body_base64.empty?
246
231
  return ::Java::MondrianSpi::SegmentBody.from_base64(segment_body_base64)
247
232
  rescue
248
233
  return nil
@@ -255,6 +240,7 @@ module MondrianRedisSegmentCache
255
240
 
256
241
  def segment_header_from_base64(segment_header_base64)
257
242
  return nil unless segment_header_base64
243
+ return nil if segment_header_base64.empty?
258
244
  return ::Java::MondrianSpi::SegmentHeader.from_base64(segment_header_base64)
259
245
  rescue
260
246
  return nil
@@ -1,3 +1,3 @@
1
1
  module MondrianRedisSegmentCache
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mondrian_redis_segment_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: java
6
6
  authors:
7
7
  - Brandon Dewitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-01 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  requirements: []
163
163
  rubyforge_project:
164
- rubygems_version: 2.4.8
164
+ rubygems_version: 2.6.9
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Segment Cache for Mondrian written in JRuby with Redis as the cache store