redis-time-series 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +26 -0
- data/CHANGELOG.md +17 -0
- data/README.md +34 -2
- data/bin/console +1 -0
- data/lib/redis-time-series.rb +1 -2
- data/lib/redis/time_series.rb +5 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23852f9c6baca09369bbcce49642070c13d1212ba2ca9e7eec93dd691702eb72
|
4
|
+
data.tar.gz: 9edac086b6fc8119382bac0777160d96279df597cdf7cb4f84d27a36532118d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8efbc6e6426d316715fc134f71d5d2d7bc334ac2d088340eba39d050185fdbd5cbf2a8d7c6cd80274e9bb3b53766905c30124d551b0d5b863180cb12c89eec0
|
7
|
+
data.tar.gz: 5a1d988f13fbace8a269b7156fea1858072a15d030439fbad38e2dfcf720503c71182267d424c5557f8bacf61305975c75c35ad2050c8e307c3b46fb8dc8b5f8
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: RSpec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
spec:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
services:
|
13
|
+
redis:
|
14
|
+
image: redislabs/redistimeseries:latest
|
15
|
+
ports:
|
16
|
+
- 6379:6379/tcp
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: 2.6
|
23
|
+
- name: Install dependencies
|
24
|
+
run: bundle install
|
25
|
+
- name: Run specs
|
26
|
+
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.1.1
|
4
|
+
Fix setting labels on `TS.CREATE` and `TS.ALTER`
|
5
|
+
|
6
|
+
## 0.1.0
|
7
|
+
|
8
|
+
Basic functionality. Includes commands:
|
9
|
+
* `TS.CREATE`
|
10
|
+
* `TS.ALTER`
|
11
|
+
* `TS.ADD`
|
12
|
+
* `TS.MADD`
|
13
|
+
* `TS.INCRBY`
|
14
|
+
* `TS.DECRBY`
|
15
|
+
* `TS.RANGE`
|
16
|
+
* `TS.GET`
|
17
|
+
* `TS.INFO`
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
![](https://github.com/dzunk/redis-time-series/workflows/RSpec/badge.svg)
|
2
|
+
|
1
3
|
# RedisTimeSeries
|
2
4
|
|
3
5
|
A Ruby adapter for the [RedisTimeSeries module](https://oss.redislabs.com/redistimeseries).
|
@@ -10,6 +12,7 @@ docker run -p 6379:6379 -it --rm redislabs/redistimeseries
|
|
10
12
|
|
11
13
|
**TL;DR**
|
12
14
|
```ruby
|
15
|
+
require 'redis-time-series'
|
13
16
|
ts = Redis::TimeSeries.new('foo')
|
14
17
|
ts.add 1234
|
15
18
|
=> #<Redis::TimeSeries::Sample:0x00007f8c0d2561d8 @time=2020-06-25 23:23:04 -0700, @value=0.1234e4>
|
@@ -48,7 +51,7 @@ Create a series (issues `TS.CREATE` command) and return a Redis::TimeSeries obje
|
|
48
51
|
```ruby
|
49
52
|
ts = Redis::TimeSeries.create(
|
50
53
|
'your_ts_key',
|
51
|
-
labels:
|
54
|
+
labels: { foo: 'bar' },
|
52
55
|
retention: 600,
|
53
56
|
uncompressed: false,
|
54
57
|
redis: Redis.new(url: ENV['REDIS_URL']) # defaults to Redis.current
|
@@ -127,6 +130,20 @@ ts.range from: 10.minutes.ago, to: Time.current # Time range as keyword args
|
|
127
130
|
#<Redis::TimeSeries::Sample:0x00007fa25dc01b68 @time=2020-06-25 23:50:57 -0700, @value=0.57e2>,
|
128
131
|
#<Redis::TimeSeries::Sample:0x00007fa25dc019b0 @time=2020-06-25 23:51:30 -0700, @value=0.58e2>]
|
129
132
|
```
|
133
|
+
Get info about the series
|
134
|
+
```ruby
|
135
|
+
ts.info
|
136
|
+
=> {"total_samples"=>3,
|
137
|
+
"memory_usage"=>4184,
|
138
|
+
"first_timestamp"=>1593155422582,
|
139
|
+
"last_timestamp"=>1593155709333,
|
140
|
+
"retention_time"=>0,
|
141
|
+
"chunk_count"=>1,
|
142
|
+
"max_samples_per_chunk"=>256,
|
143
|
+
"labels"=>[],
|
144
|
+
"source_key"=>nil,
|
145
|
+
"rules"=>[]}
|
146
|
+
```
|
130
147
|
|
131
148
|
### TODO
|
132
149
|
* `TS.REVRANGE`
|
@@ -140,7 +157,22 @@ ts.range from: 10.minutes.ago, to: Time.current # Time range as keyword args
|
|
140
157
|
|
141
158
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
142
159
|
|
143
|
-
|
160
|
+
In order to run the specs or use the console, you'll need a Redis server running on the default port 6379 with the RedisTimeSeries module enabled. The easiest way to do so is by running the Docker image:
|
161
|
+
```
|
162
|
+
docker run -p 6379:6379 -it --rm redislabs/redistimeseries
|
163
|
+
```
|
164
|
+
|
165
|
+
The `bin/console` script will set up three time series, `@ts1`, `@ts2`, and `@ts3`, with three values in each. **It will also flush the local Redis server each time you run it**, so don't try it if you have data you don't want to lose!
|
166
|
+
|
167
|
+
If you want to see the commands being executed, run the console with `DEBUG=true bin/console` and it will output the raw command strings as they're executed.
|
168
|
+
```ruby
|
169
|
+
[1] pry(main)> @ts1.increment
|
170
|
+
DEBUG: TS.INCRBY foo 1
|
171
|
+
=> 1593159795467
|
172
|
+
[2] pry(main)> @ts1.get
|
173
|
+
DEBUG: TS.GET foo
|
174
|
+
=> #<Redis::TimeSeries::Sample:0x00007f8e1a190cf8 @time=2020-06-26 01:23:15 -0700, @value=0.4e1>
|
175
|
+
```
|
144
176
|
|
145
177
|
## Contributing
|
146
178
|
|
data/bin/console
CHANGED
data/lib/redis-time-series.rb
CHANGED
data/lib/redis/time_series.rb
CHANGED
@@ -59,10 +59,10 @@ class Redis
|
|
59
59
|
|
60
60
|
def create
|
61
61
|
args = [key]
|
62
|
-
args <<
|
63
|
-
args <<
|
64
|
-
args <<
|
65
|
-
cmd 'TS.CREATE', args
|
62
|
+
args << ['RETENTION', retention] if retention
|
63
|
+
args << 'UNCOMPRESSED' if uncompressed
|
64
|
+
args << ['LABELS', labels.to_a] if labels.any?
|
65
|
+
cmd 'TS.CREATE', args.flatten
|
66
66
|
self
|
67
67
|
end
|
68
68
|
|
@@ -101,7 +101,7 @@ class Redis
|
|
101
101
|
|
102
102
|
def labels=(val)
|
103
103
|
@labels = val
|
104
|
-
cmd 'TS.ALTER', key, 'LABELS',
|
104
|
+
cmd 'TS.ALTER', key, 'LABELS', labels.to_a.flatten
|
105
105
|
end
|
106
106
|
|
107
107
|
def madd(*values)
|
@@ -153,9 +153,5 @@ class Redis
|
|
153
153
|
puts "DEBUG: #{name} #{args.join(' ')}" if ENV['DEBUG']
|
154
154
|
redis.call name, *args
|
155
155
|
end
|
156
|
-
|
157
|
-
def label_string
|
158
|
-
labels.map { |label, value| "#{label} #{value}" }.join(' ')
|
159
|
-
end
|
160
156
|
end
|
161
157
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-time-series
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Duszynski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -101,6 +101,7 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
+
- ".github/workflows/rspec.yml"
|
104
105
|
- ".gitignore"
|
105
106
|
- ".rspec"
|
106
107
|
- CHANGELOG.md
|