redis_counters 1.5.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/.drone.yml +79 -19
- data/Appraisals +9 -0
- data/CHANGELOG.md +59 -41
- data/dip.yml +1 -0
- data/docker-compose.yml +7 -0
- data/lib/redis_counters/version.rb +1 -1
- data/redis_counters.gemspec +3 -3
- data/spec/redis_counters/base_spec.rb +2 -2
- data/spec/redis_counters/hash_counter_spec.rb +31 -35
- data/spec/redis_counters/unique_hash_counter_spec.rb +5 -5
- data/spec/redis_counters/unique_values_lists/blocking_spec.rb +2 -2
- data/spec/spec_helper.rb +4 -1
- data/spec/support/unique_values_lists/common.rb +12 -13
- data/spec/support/unique_values_lists/expirable.rb +2 -3
- data/spec/support/unique_values_lists/set.rb +2 -3
- metadata +23 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98ed479650224ea88e6e4bd246261c38f9aad322
|
|
4
|
+
data.tar.gz: 935fca9f98e46caed3bb0fec2326297659bfae0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fad9d9cf5db41a260a2f40c4893ced84ada4a40c350ad383455edd9867cd3581b881af2bb3cd73262b95363fc8a8f02e0ed74ec65b1203d8379edf888f25c1bf
|
|
7
|
+
data.tar.gz: 889bf55c4d9d95fc056130aa5cf72db60784e3f3a29af928799db2c0e1cebfcf77d9b3eb572c7e1eb62801d43e92ae2f340a91a9a42c9491055cc77515f9fc6d
|
data/.drone.yml
CHANGED
|
@@ -1,22 +1,82 @@
|
|
|
1
|
-
build
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
name: build
|
|
2
|
+
|
|
3
|
+
kind: pipeline
|
|
4
|
+
type: docker
|
|
5
|
+
|
|
6
|
+
volumes:
|
|
7
|
+
- name: rubygems
|
|
8
|
+
host:
|
|
9
|
+
path: /home/data/drone/rubygems
|
|
10
|
+
- name: images
|
|
11
|
+
host:
|
|
12
|
+
path: /home/data/drone/images
|
|
13
|
+
- name: bundle
|
|
14
|
+
host:
|
|
15
|
+
path: /home/data/drone/gems
|
|
16
|
+
- name: keys
|
|
17
|
+
host:
|
|
18
|
+
path: /home/data/drone/key_cache
|
|
19
|
+
|
|
20
|
+
spec_step_common: &spec_step_common
|
|
21
|
+
image: abakpress/dind-testing:1.0.3
|
|
22
|
+
pull: if-not-exists
|
|
23
|
+
privileged: true
|
|
24
|
+
volumes:
|
|
25
|
+
- name: images
|
|
26
|
+
path: /images
|
|
27
|
+
- name: bundle
|
|
28
|
+
path: /bundle
|
|
29
|
+
- name: keys
|
|
30
|
+
path: /ssh_keys
|
|
31
|
+
commands:
|
|
32
|
+
- prepare-build
|
|
33
|
+
|
|
34
|
+
- fetch-images
|
|
35
|
+
--image whilp/ssh-agent
|
|
36
|
+
--image abakpress/ruby-app:$RUBY_IMAGE_TAG
|
|
37
|
+
--image redis:$REDIS_IMAGE_TAG
|
|
38
|
+
|
|
39
|
+
- dip ssh add -T -v /ssh_keys -k /ssh_keys/id_rsa
|
|
40
|
+
- dip provision
|
|
41
|
+
- dip rspec
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Tests Ruby 2.2
|
|
9
45
|
environment:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
46
|
+
COMPOSE_FILE_EXT: drone
|
|
47
|
+
DOCKER_RUBY_VERSION: 2.2
|
|
48
|
+
RUBY_IMAGE_TAG: 2.2-latest
|
|
49
|
+
REDIS_IMAGE_TAG: 4-alpine
|
|
50
|
+
RAILS_ENV: test
|
|
51
|
+
<<: *spec_step_common
|
|
52
|
+
|
|
53
|
+
- name: Tests Ruby 2.3
|
|
54
|
+
environment:
|
|
55
|
+
COMPOSE_FILE_EXT: drone
|
|
56
|
+
DOCKER_RUBY_VERSION: 2.3
|
|
57
|
+
RUBY_IMAGE_TAG: 2.3-latest
|
|
58
|
+
REDIS_IMAGE_TAG: 4-alpine
|
|
59
|
+
RAILS_ENV: test
|
|
60
|
+
<<: *spec_step_common
|
|
15
61
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
62
|
+
- name: Tests Ruby 2.4
|
|
63
|
+
environment:
|
|
64
|
+
COMPOSE_FILE_EXT: drone
|
|
65
|
+
DOCKER_RUBY_VERSION: 2.4
|
|
66
|
+
RUBY_IMAGE_TAG: 2.4-latest
|
|
67
|
+
REDIS_IMAGE_TAG: 4-alpine
|
|
68
|
+
RAILS_ENV: test
|
|
69
|
+
<<: *spec_step_common
|
|
20
70
|
|
|
21
|
-
|
|
22
|
-
|
|
71
|
+
- name: release
|
|
72
|
+
image: abakpress/gem-publication:latest
|
|
73
|
+
pull: if-not-exists
|
|
74
|
+
when:
|
|
75
|
+
event: push
|
|
76
|
+
branch: master
|
|
77
|
+
status: success
|
|
78
|
+
volumes:
|
|
79
|
+
- name: rubygems
|
|
80
|
+
path: /root/.gem
|
|
81
|
+
commands:
|
|
82
|
+
- release-gem --public
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,42 +1,60 @@
|
|
|
1
|
+
# v1.5.1
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
3
|
+
* 2021-08-06 [3302af4](../../commit/3302af4) - __(TamarinEA)__ Release 1.5.1
|
|
4
|
+
* 2021-08-06 [09ed078](../../commit/09ed078) - __(TamarinEA)__ chore: support ruby 2.4 and use redis in test
|
|
5
|
+
|
|
6
|
+
# v1.5.0
|
|
7
|
+
|
|
8
|
+
* 2017-04-21 [d64da5e](../../commit/d64da5e) - __(Pavel Galkin)__ feat: support two value delimiters
|
|
9
|
+
https://jira.railsc.ru/browse/CK-862
|
|
10
|
+
|
|
11
|
+
* 2017-04-21 [a4f458c](../../commit/a4f458c) - __(Pavel Galkin)__ chore: update infrastructure
|
|
12
|
+
|
|
13
|
+
# v1.4.0
|
|
14
|
+
|
|
15
|
+
* 2016-07-20 [e6be297](../../commit/e6be297) - __(Stanislav Gordanov)__ feat: переместит значение инкремента в начало массива данных
|
|
16
|
+
* 2015-07-26 [e4771c5](../../commit/e4771c5) - __(Artem Napolskih)__ Update README.md
|
|
17
|
+
* 2015-02-19 [c86a1aa](../../commit/c86a1aa) - __(bibendi)__ commit changelog after generate it
|
|
18
|
+
* 2015-02-19 [b5ec9f8](../../commit/b5ec9f8) - __(bibendi)__ change releasing tasks to upload on rubygems
|
|
19
|
+
|
|
20
|
+
# v1.2.0
|
|
21
|
+
|
|
22
|
+
* 2014-11-10 [6257dc2](../../commit/6257dc2) - __(Artem Napolskih)__ feature(hash_counter): added float mode
|
|
23
|
+
* 2014-10-17 [48deb40](../../commit/48deb40) - __(Artem Napolskih)__ feature(unique_values_list): introduced a list of unique values to expiry of the members
|
|
24
|
+
* 2014-10-17 [e1206b7](../../commit/e1206b7) - __(Artem Napolskih)__ feature(unique_values_list): introduce has_value? method
|
|
25
|
+
* 2014-10-17 [cccc2be](../../commit/cccc2be) - __(Artem Napolskih)__ feature(unique_values_list): rename Standard and Fast unique values list to Blocking and NonBlocking respectively
|
|
26
|
+
* 2014-10-17 [7521fd8](../../commit/7521fd8) - __(Artem Napolskih)__ chore(specs): reorganize unique lists specs
|
|
27
|
+
* 2014-04-23 [94fada3](../../commit/94fada3) - __(Artem Napolskih)__ chore(all): fix circleci badge
|
|
28
|
+
* 2013-11-20 [0ae5531](../../commit/0ae5531) - __(Artem Napolskih)__ Release 1.1.0
|
|
29
|
+
|
|
30
|
+
# v1.1.0
|
|
31
|
+
|
|
32
|
+
* 2013-11-20 [3897988](../../commit/3897988) - __(Artem Napolskih)__ refactor(all): back delete_all! methods
|
|
33
|
+
* 2013-11-15 [2d1c733](../../commit/2d1c733) - __(Artem Napolskih)__ refactor(all): extract Cluster and Partition classes
|
|
34
|
+
* 2013-10-22 [020cc8e](../../commit/020cc8e) - __(Napolskih)__ refactor(all): shared code of clustering and partitioning extracted into module - group_keys -> cluster_keys - shared code of clustering and partitioning extracted into module
|
|
35
|
+
|
|
36
|
+
# v1.0.1
|
|
37
|
+
|
|
38
|
+
* 2013-10-21 [bfa328a](../../commit/bfa328a) - __(Artem Napolskih)__ feature(hash_counter): method date when called with a block, now returns the total number of lines
|
|
39
|
+
* 2013-10-21 [6d04c95](../../commit/6d04c95) - __(Artem Napolskih)__ Release 1.0.0
|
|
40
|
+
* 2013-10-10 [b29eab7](../../commit/b29eab7) - __(Artem Napolskih)__ feature(unique_values_lists): added methods to read and delete data
|
|
41
|
+
* 2013-10-10 [67c5200](../../commit/67c5200) - __(Artem Napolskih)__ feature(unique_hash_counter): introduce unique list postfix delimiter
|
|
42
|
+
* 2013-10-08 [8a9a2a9](../../commit/8a9a2a9) - __(Artem Napolskih)__ feature(hash_counter): added methods to read and delete data
|
|
43
|
+
* 2013-09-13 [f8d037c](../../commit/f8d037c) - __(Artem Napolskih)__ docs(all): documenting
|
|
44
|
+
|
|
45
|
+
# v1.0.0beta1
|
|
46
|
+
|
|
47
|
+
# v1.0.0
|
|
48
|
+
|
|
49
|
+
* 2013-10-10 [b29eab7](../../commit/b29eab7) - __(Artem Napolskih)__ feature(unique_values_lists): added methods to read and delete data
|
|
50
|
+
* 2013-10-10 [67c5200](../../commit/67c5200) - __(Artem Napolskih)__ feature(unique_hash_counter): introduce unique list postfix delimiter
|
|
51
|
+
* 2013-10-08 [8a9a2a9](../../commit/8a9a2a9) - __(Artem Napolskih)__ feature(hash_counter): added methods to read and delete data
|
|
52
|
+
* 2013-09-13 [f8d037c](../../commit/f8d037c) - __(Artem Napolskih)__ docs(all): documenting
|
|
53
|
+
* 2013-09-12 [0a176fa](../../commit/0a176fa) - __(Artem Napolskih)__ feature(all) introduce key and value delimiters
|
|
54
|
+
* 2013-09-12 [addbb40](../../commit/addbb40) - __(Artem Napolskih)__ feature(unique_values_list): fast (non blocking) unique values list added
|
|
55
|
+
- refactoring unique_values_list;
|
|
56
|
+
- fast (non blocking) unique values list added;
|
|
57
|
+
- unique_list[:list_class] property introduced on UniqueHashCounter.
|
|
58
|
+
|
|
59
|
+
* 2013-08-23 [897418d](../../commit/897418d) - __(Artem Napolskih)__ Initial commit
|
|
60
|
+
* 2013-08-21 [21ed53b](../../commit/21ed53b) - __(napolskih)__ dummy commit
|
data/dip.yml
CHANGED
data/docker-compose.yml
CHANGED
|
@@ -6,4 +6,11 @@ services:
|
|
|
6
6
|
environment:
|
|
7
7
|
- BUNDLE_PATH=/bundle/$DOCKER_RUBY_VERSION
|
|
8
8
|
- BUNDLE_CONFIG=/app/.bundle/config
|
|
9
|
+
- TEST_REDIS_HOST=redis
|
|
9
10
|
command: bash
|
|
11
|
+
depends_on:
|
|
12
|
+
- redis
|
|
13
|
+
|
|
14
|
+
redis:
|
|
15
|
+
image: redis:$REDIS_IMAGE_TAG
|
|
16
|
+
command: 'redis-server --bind 0.0.0.0'
|
data/redis_counters.gemspec
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'redis_counters/version'
|
|
@@ -16,12 +15,13 @@ Gem::Specification.new do |spec|
|
|
|
16
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
17
16
|
spec.require_paths = ['lib']
|
|
18
17
|
|
|
19
|
-
spec.
|
|
18
|
+
spec.add_runtime_dependency 'activesupport', '>= 4.0', '< 5'
|
|
20
19
|
|
|
21
20
|
spec.add_development_dependency 'bundler'
|
|
22
21
|
spec.add_development_dependency 'rake'
|
|
23
22
|
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
|
24
|
-
spec.add_development_dependency '
|
|
23
|
+
spec.add_development_dependency 'redis', '>= 3.0'
|
|
24
|
+
spec.add_development_dependency 'appraisal', '>= 1.0.2'
|
|
25
25
|
spec.add_development_dependency 'timecop'
|
|
26
26
|
spec.add_development_dependency 'codeclimate-test-reporter', '>= 0.4.1'
|
|
27
27
|
spec.add_development_dependency 'simplecov'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe RedisCounters::BaseCounter do
|
|
4
|
-
let(:redis) {
|
|
4
|
+
let(:redis) { Redis.current }
|
|
5
5
|
|
|
6
6
|
let(:options) { {
|
|
7
7
|
:counter_class => RedisCounters::HashCounter,
|
|
@@ -26,4 +26,4 @@ describe RedisCounters::BaseCounter do
|
|
|
26
26
|
|
|
27
27
|
it { expect { counter }.to raise_error KeyError }
|
|
28
28
|
end
|
|
29
|
-
end
|
|
29
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe RedisCounters::HashCounter do
|
|
4
|
-
let(:redis) {
|
|
4
|
+
let(:redis) { Redis.current }
|
|
5
5
|
let(:value) { rand(10) + 1 }
|
|
6
6
|
let(:options) { { :counter_name => :test_counter, :field_name => :test_field } }
|
|
7
7
|
let(:counter) { described_class.new(redis, options) }
|
|
@@ -89,8 +89,7 @@ describe RedisCounters::HashCounter do
|
|
|
89
89
|
before { 3.times { counter.process(:param1 => 21, :param2 => 22, :param3 => 33) } }
|
|
90
90
|
|
|
91
91
|
it { expect(redis.keys('*')).to have(2).key }
|
|
92
|
-
it { expect(redis.keys('*')
|
|
93
|
-
it { expect(redis.keys('*').last).to eq 'test_counter:21:22' }
|
|
92
|
+
it { expect(redis.keys('*')).to match_array ['test_counter:11:22', 'test_counter:21:22'] }
|
|
94
93
|
it { expect(redis.hexists('test_counter:11:22', 'test_field')).to be_true }
|
|
95
94
|
it { expect(redis.hget('test_counter:11:22', 'test_field')).to eq value.to_s }
|
|
96
95
|
it { expect(redis.hexists('test_counter:21:22', 'test_field')).to be_true }
|
|
@@ -108,8 +107,7 @@ describe RedisCounters::HashCounter do
|
|
|
108
107
|
before { 3.times { counter.process(:param1 => 2, :param2 => 2) } }
|
|
109
108
|
|
|
110
109
|
it { expect(redis.keys('*')).to have(2).key }
|
|
111
|
-
it { expect(redis.keys('*')
|
|
112
|
-
it { expect(redis.keys('*').last).to eq 'test_counter:false' }
|
|
110
|
+
it { expect(redis.keys('*')).to match_array ['test_counter:true', 'test_counter:false'] }
|
|
113
111
|
it { expect(redis.hexists('test_counter:true', 'test_field')).to be_true }
|
|
114
112
|
it { expect(redis.hget('test_counter:true', 'test_field')).to eq 2.to_s }
|
|
115
113
|
it { expect(redis.hexists('test_counter:false', 'test_field')).to be_true }
|
|
@@ -129,9 +127,7 @@ describe RedisCounters::HashCounter do
|
|
|
129
127
|
before { 1.times { counter.process(:param1 => 21, :param2 => '', :param3 => 33) } }
|
|
130
128
|
|
|
131
129
|
it { expect(redis.keys('*')).to have(3).key }
|
|
132
|
-
it { expect(redis.keys('*')
|
|
133
|
-
it { expect(redis.keys('*').second).to eq 'test_counter:21:22' }
|
|
134
|
-
it { expect(redis.keys('*').third).to eq 'test_counter:21:' }
|
|
130
|
+
it { expect(redis.keys('*')).to match_array ['test_counter:11:22', 'test_counter:21:22', 'test_counter:21:'] }
|
|
135
131
|
it { expect(redis.hexists('test_counter:11:22', 'test_field')).to be_true }
|
|
136
132
|
it { expect(redis.hget('test_counter:11:22', 'test_field')).to eq value.to_s }
|
|
137
133
|
it { expect(redis.hexists('test_counter:21:22', 'test_field')).to be_true }
|
|
@@ -153,9 +149,13 @@ describe RedisCounters::HashCounter do
|
|
|
153
149
|
before { 1.times { counter.process(:param1 => 2, :param2 => 2, :date => '2013-04-28') } }
|
|
154
150
|
|
|
155
151
|
it { expect(redis.keys('*')).to have(3).key }
|
|
156
|
-
it
|
|
157
|
-
|
|
158
|
-
|
|
152
|
+
it do
|
|
153
|
+
expect(redis.keys('*')).to match_array [
|
|
154
|
+
'test_counter:2013-04-27:true',
|
|
155
|
+
'test_counter:2013-04-27:false',
|
|
156
|
+
'test_counter:2013-04-28:false'
|
|
157
|
+
]
|
|
158
|
+
end
|
|
159
159
|
it { expect(redis.hexists('test_counter:2013-04-27:true', 'test_field')).to be_true }
|
|
160
160
|
it { expect(redis.hget('test_counter:2013-04-27:true', 'test_field')).to eq 3.to_s }
|
|
161
161
|
it { expect(redis.hexists('test_counter:2013-04-27:false', 'test_field')).to be_true }
|
|
@@ -182,17 +182,14 @@ describe RedisCounters::HashCounter do
|
|
|
182
182
|
|
|
183
183
|
context 'when no partition params given' do
|
|
184
184
|
it { expect(counter.partitions).to have(3).partition }
|
|
185
|
-
it { expect(counter.partitions
|
|
186
|
-
it { expect(counter.partitions.second).to eq partition_2 }
|
|
187
|
-
it { expect(counter.partitions.third).to eq partition_3 }
|
|
185
|
+
it { expect(counter.partitions).to match_array [partition_1, partition_2, partition_3] }
|
|
188
186
|
end
|
|
189
187
|
|
|
190
188
|
context 'when one partition param given' do
|
|
191
189
|
it { expect(counter.partitions(:param1 => 11)).to have(1).partition }
|
|
192
190
|
it { expect(counter.partitions(:param1 => 11).first).to eq partition_1 }
|
|
193
191
|
it { expect(counter.partitions(:param1 => 21)).to have(2).partition }
|
|
194
|
-
it { expect(counter.partitions(:param1 => 21)
|
|
195
|
-
it { expect(counter.partitions('param1' => 21).second).to eq partition_3 }
|
|
192
|
+
it { expect(counter.partitions(:param1 => 21)).to match_array [partition_2, partition_3] }
|
|
196
193
|
end
|
|
197
194
|
|
|
198
195
|
context 'when two partition params given' do
|
|
@@ -231,9 +228,7 @@ describe RedisCounters::HashCounter do
|
|
|
231
228
|
before { 4.times { counter.process(:param1 => 21, :param2 => '', :param3 => 31) } }
|
|
232
229
|
|
|
233
230
|
it { expect(counter.data(partitions)).to have(3).row }
|
|
234
|
-
it { expect(counter.data(partitions)
|
|
235
|
-
it { expect(counter.data(partitions).second[:value]).to eq 2 }
|
|
236
|
-
it { expect(counter.data(partitions).third[:value]).to eq 5 }
|
|
231
|
+
it { expect(counter.data(partitions)).to match_array [{'value' => 3}, {'value' => 2}, {'value' => 5}] }
|
|
237
232
|
end
|
|
238
233
|
|
|
239
234
|
context 'when group_keys and one group key is nil' do
|
|
@@ -375,8 +370,7 @@ describe RedisCounters::HashCounter do
|
|
|
375
370
|
before { counter.delete_partitions!(partition_2) }
|
|
376
371
|
|
|
377
372
|
it { expect(counter.partitions).to have(2).row }
|
|
378
|
-
it { expect(counter.partitions
|
|
379
|
-
it { expect(counter.partitions.last).to eq partition_3 }
|
|
373
|
+
it { expect(counter.partitions).to match_array [partition_1, partition_3] }
|
|
380
374
|
end
|
|
381
375
|
|
|
382
376
|
context 'when not leaf partition given' do
|
|
@@ -396,9 +390,7 @@ describe RedisCounters::HashCounter do
|
|
|
396
390
|
before { counter.delete_partitions!(:param1 => 21, &error_proc) rescue nil }
|
|
397
391
|
|
|
398
392
|
it { expect(counter.partitions).to have(3).row }
|
|
399
|
-
it { expect(counter.partitions
|
|
400
|
-
it { expect(counter.partitions.second).to eq partition_2 }
|
|
401
|
-
it { expect(counter.partitions.last).to eq partition_3 }
|
|
393
|
+
it { expect(counter.partitions).to match_array [partition_1, partition_2, partition_3] }
|
|
402
394
|
end
|
|
403
395
|
end
|
|
404
396
|
|
|
@@ -407,8 +399,7 @@ describe RedisCounters::HashCounter do
|
|
|
407
399
|
before { counter.delete_partitions!(partition_2) }
|
|
408
400
|
|
|
409
401
|
it { expect(counter.partitions).to have(2).row }
|
|
410
|
-
it { expect(counter.partitions
|
|
411
|
-
it { expect(counter.partitions.last).to eq partition_3 }
|
|
402
|
+
it { expect(counter.partitions).to match_array [partition_1, partition_3] }
|
|
412
403
|
end
|
|
413
404
|
|
|
414
405
|
context 'when not leaf partition given' do
|
|
@@ -434,16 +425,21 @@ describe RedisCounters::HashCounter do
|
|
|
434
425
|
before { 2.times { counter.process(partition_2) } }
|
|
435
426
|
before { 3.times { counter.process(partition_3) } }
|
|
436
427
|
|
|
437
|
-
it
|
|
438
|
-
|
|
439
|
-
|
|
428
|
+
it do
|
|
429
|
+
expect(counter.partitions).to match_array [
|
|
430
|
+
{'param1' => '11', 'param2' => '22:35'},
|
|
431
|
+
{'param1' => '11', 'param2' => '23:26'},
|
|
432
|
+
{'param1' => '11', 'param2' => '24:26'}
|
|
433
|
+
]
|
|
434
|
+
end
|
|
440
435
|
|
|
441
|
-
it
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
436
|
+
it do
|
|
437
|
+
expect(counter.data).to match_array [
|
|
438
|
+
{'value' => 1, 'param3' => '11:64'},
|
|
439
|
+
{'value' => 2, 'param3' => '11:36'},
|
|
440
|
+
{'value' => 3, 'param3' => '21:54'}
|
|
441
|
+
]
|
|
442
|
+
end
|
|
447
443
|
end
|
|
448
444
|
|
|
449
445
|
context 'two delimiters' do
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe RedisCounters::UniqueHashCounter do
|
|
4
|
-
let(:redis) {
|
|
4
|
+
let(:redis) { Redis.current }
|
|
5
5
|
let(:unique_list_postfix) { described_class.const_get(:UNIQUE_LIST_POSTFIX) }
|
|
6
6
|
|
|
7
7
|
let(:options) { {
|
|
@@ -76,8 +76,8 @@ describe RedisCounters::UniqueHashCounter do
|
|
|
76
76
|
|
|
77
77
|
it { expect(redis.lrange('test_counter_uq:1:partitions', 0, -1)).to eq ['2013-04-28', '2013-04-27'] }
|
|
78
78
|
it { expect(redis.lrange('test_counter_uq:2:partitions', 0, -1)).to eq ['2013-04-27'] }
|
|
79
|
-
it { expect(redis.smembers('test_counter_uq:1:2013-04-27')).to
|
|
80
|
-
it { expect(redis.smembers('test_counter_uq:2:2013-04-27')).to
|
|
81
|
-
it { expect(redis.smembers('test_counter_uq:1:2013-04-28')).to
|
|
79
|
+
it { expect(redis.smembers('test_counter_uq:1:2013-04-27')).to match_array ['4'] }
|
|
80
|
+
it { expect(redis.smembers('test_counter_uq:2:2013-04-27')).to match_array ['3', '2', '1'] }
|
|
81
|
+
it { expect(redis.smembers('test_counter_uq:1:2013-04-28')).to match_array ['5', '1'] }
|
|
82
82
|
end
|
|
83
|
-
end
|
|
83
|
+
end
|
|
@@ -5,7 +5,7 @@ describe RedisCounters::UniqueValuesLists::Blocking do
|
|
|
5
5
|
it_behaves_like 'unique_values_lists/set'
|
|
6
6
|
|
|
7
7
|
context 'when check partitions list' do
|
|
8
|
-
let(:redis) {
|
|
8
|
+
let(:redis) { Redis.current }
|
|
9
9
|
let(:values) { rand(10) + 1 }
|
|
10
10
|
let(:partitions_list_postfix) { described_class.const_get(:PARTITIONS_LIST_POSTFIX) }
|
|
11
11
|
|
|
@@ -91,4 +91,4 @@ describe RedisCounters::UniqueValuesLists::Blocking do
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
-
end
|
|
94
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'bundler/setup'
|
|
2
2
|
require 'rspec'
|
|
3
|
-
require 'mock_redis'
|
|
4
3
|
require 'timecop'
|
|
5
4
|
require 'codeclimate-test-reporter'
|
|
6
5
|
require 'simplecov'
|
|
@@ -9,6 +8,9 @@ require 'pry-byebug'
|
|
|
9
8
|
SimpleCov.start('test_frameworks')
|
|
10
9
|
|
|
11
10
|
require 'redis_counters'
|
|
11
|
+
require 'redis'
|
|
12
|
+
|
|
13
|
+
Redis.current = Redis.new(host: ENV['TEST_REDIS_HOST'])
|
|
12
14
|
|
|
13
15
|
# require helpers
|
|
14
16
|
support_dir = File.expand_path(File.join('..', 'support'), __FILE__)
|
|
@@ -16,4 +18,5 @@ Dir[File.join(support_dir, '**', '*.rb')].each { |f| require f }
|
|
|
16
18
|
|
|
17
19
|
RSpec.configure do |config|
|
|
18
20
|
config.backtrace_exclusion_patterns = [/lib\/rspec\/(core|expectations|matchers|mocks)/]
|
|
21
|
+
config.before { Redis.current.flushdb }
|
|
19
22
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
shared_examples_for 'unique_values_lists/common' do
|
|
3
|
-
let(:redis) {
|
|
2
|
+
let(:redis) { Redis.current }
|
|
4
3
|
let(:values) { rand(10) + 1 }
|
|
5
4
|
|
|
6
5
|
let(:options) { {
|
|
@@ -139,9 +138,10 @@ shared_examples_for 'unique_values_lists/common' do
|
|
|
139
138
|
|
|
140
139
|
context 'when no partition given' do
|
|
141
140
|
it { expect(counter.partitions(cluster1_subcluster1)).to have(3).partitions }
|
|
142
|
-
it
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
it do
|
|
142
|
+
expect(counter.partitions(cluster1_subcluster1)).
|
|
143
|
+
to match_array [part1_subpart1, part1_subpart2, part2_subpart1]
|
|
144
|
+
end
|
|
145
145
|
#
|
|
146
146
|
it { expect(counter.partitions(cluster2_subcluster1)).to have(1).partitions }
|
|
147
147
|
it { expect(counter.partitions(cluster2_subcluster1).first).to eq part1_subpart1 }
|
|
@@ -149,8 +149,10 @@ shared_examples_for 'unique_values_lists/common' do
|
|
|
149
149
|
|
|
150
150
|
context 'when not leaf partition given' do
|
|
151
151
|
it { expect(counter.partitions(cluster1_subcluster1.merge(:part => :part1))).to have(2).partitions }
|
|
152
|
-
it
|
|
153
|
-
|
|
152
|
+
it do
|
|
153
|
+
expect(counter.partitions(cluster1_subcluster1.merge(:part => :part1))).
|
|
154
|
+
to match_array [part1_subpart1, part1_subpart2]
|
|
155
|
+
end
|
|
154
156
|
end
|
|
155
157
|
|
|
156
158
|
context 'when leaf partition given' do
|
|
@@ -182,15 +184,12 @@ shared_examples_for 'unique_values_lists/common' do
|
|
|
182
184
|
|
|
183
185
|
context 'when no partition given' do
|
|
184
186
|
it { expect(counter.partitions).to have(3).partitions }
|
|
185
|
-
it { expect(counter.partitions
|
|
186
|
-
it { expect(counter.partitions.second).to eq part1_subpart2 }
|
|
187
|
-
it { expect(counter.partitions.third).to eq part2_subpart1 }
|
|
187
|
+
it { expect(counter.partitions).to match_array [part1_subpart1, part1_subpart2, part2_subpart1] }
|
|
188
188
|
end
|
|
189
189
|
|
|
190
190
|
context 'when not leaf partition given' do
|
|
191
191
|
it { expect(counter.partitions(:part => :part1)).to have(2).partitions }
|
|
192
|
-
it { expect(counter.partitions(:part => :part1)
|
|
193
|
-
it { expect(counter.partitions(:part => :part1).second).to eq part1_subpart2 }
|
|
192
|
+
it { expect(counter.partitions(:part => :part1)).to match_array [part1_subpart1, part1_subpart2] }
|
|
194
193
|
end
|
|
195
194
|
|
|
196
195
|
context 'when leaf partition given' do
|
|
@@ -560,4 +559,4 @@ shared_examples_for 'unique_values_lists/common' do
|
|
|
560
559
|
end
|
|
561
560
|
end
|
|
562
561
|
end
|
|
563
|
-
end
|
|
562
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
shared_examples_for 'unique_values_lists/expirable' do
|
|
3
|
-
let(:redis) {
|
|
2
|
+
let(:redis) { Redis.current }
|
|
4
3
|
let(:counter) { described_class.new(redis, options) }
|
|
5
4
|
|
|
6
5
|
after do
|
|
@@ -159,4 +158,4 @@ shared_examples_for 'unique_values_lists/expirable' do
|
|
|
159
158
|
end
|
|
160
159
|
end
|
|
161
160
|
end
|
|
162
|
-
end
|
|
161
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
1
|
shared_examples_for 'unique_values_lists/set' do
|
|
3
|
-
let(:redis) {
|
|
2
|
+
let(:redis) { Redis.current }
|
|
4
3
|
let(:values) { rand(10) + 1 }
|
|
5
4
|
|
|
6
5
|
let(:counter) { described_class.new(redis, options) }
|
|
@@ -116,4 +115,4 @@ shared_examples_for 'unique_values_lists/set' do
|
|
|
116
115
|
it { expect(redis.smembers("test_counter:cluster2")).to include '4:5' }
|
|
117
116
|
end
|
|
118
117
|
end
|
|
119
|
-
end
|
|
118
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redis_counters
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Artem Napolskih
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-08-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,7 +16,7 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '4.0'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
22
|
version: '5'
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '
|
|
29
|
+
version: '4.0'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '5'
|
|
@@ -73,19 +73,33 @@ dependencies:
|
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
74
|
version: 2.14.0
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
76
|
+
name: redis
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - ">="
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '0'
|
|
81
|
+
version: '3.0'
|
|
82
82
|
type: :development
|
|
83
83
|
prerelease: false
|
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
85
|
requirements:
|
|
86
86
|
- - ">="
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '0'
|
|
88
|
+
version: '3.0'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
name: appraisal
|
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: 1.0.2
|
|
96
|
+
type: :development
|
|
97
|
+
prerelease: false
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 1.0.2
|
|
89
103
|
- !ruby/object:Gem::Dependency
|
|
90
104
|
name: timecop
|
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -180,6 +194,7 @@ files:
|
|
|
180
194
|
- ".drone.yml"
|
|
181
195
|
- ".gitignore"
|
|
182
196
|
- ".rspec"
|
|
197
|
+
- Appraisals
|
|
183
198
|
- CHANGELOG.md
|
|
184
199
|
- Gemfile
|
|
185
200
|
- Makefile
|
|
@@ -237,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
237
252
|
version: '0'
|
|
238
253
|
requirements: []
|
|
239
254
|
rubyforge_project:
|
|
240
|
-
rubygems_version: 2.
|
|
255
|
+
rubygems_version: 2.6.1
|
|
241
256
|
signing_key:
|
|
242
257
|
specification_version: 4
|
|
243
258
|
summary: Redis Counters
|