simple_throttle 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -3
- data/VERSION +1 -1
- data/lib/simple_throttle.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88bc1f488ffad8621894918d48bbde5df0c68ef498ddaaf359d91f81914a27c5
|
4
|
+
data.tar.gz: c219a0b2a6b66e1e5427bdab8260dcfc4f0121618fd8c340a3e892f92dad1192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e30ae0a0a4dbfb09778fc1cfcd02d3376b020fc83d4166a2ab6066725a4c2c0e8680f38ac26c127b6b0952ed4558ff9c3e82e0301dda0dc4db9bf831cb8c383
|
7
|
+
data.tar.gz: 5cfb1b4e72a4b1014a131b50ddb028e41289b102016b54ba2a5eef4c03d2f7a5edd66b21c84924be54df1e01796d0c1c2c963a7cf8072bfc1ca7951bab983a47
|
data/CHANGELOG.md
CHANGED
@@ -4,12 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 1.0.3
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
- Ensure that arguments sent to Redis Lua script are cast to integers.
|
11
|
+
|
7
12
|
## 1.0.2
|
8
13
|
|
9
14
|
### Added
|
10
|
-
- Throttle insances can now specify the Redis instance to override the global setting
|
11
|
-
- Redis instance now defaults to the default redis instance: `Redis.new
|
12
|
-
- Optimize loading LUA script to Redis; now done globally instead of per throttle instance
|
15
|
+
- Throttle insances can now specify the Redis instance to override the global setting.
|
16
|
+
- Redis instance now defaults to the default redis instance: `Redis.new`.
|
17
|
+
- Optimize loading LUA script to Redis; now done globally instead of per throttle instance.
|
13
18
|
|
14
19
|
|
15
20
|
## 1.0.1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/lib/simple_throttle.rb
CHANGED
@@ -101,8 +101,8 @@ class SimpleThrottle
|
|
101
101
|
def initialize(name, ttl:, limit:, redis: nil)
|
102
102
|
@name = name.to_s
|
103
103
|
@name = name.dup.freeze unless name.frozen?
|
104
|
-
@limit = limit
|
105
|
-
@ttl = ttl
|
104
|
+
@limit = limit.to_i
|
105
|
+
@ttl = ttl.to_f
|
106
106
|
@redis = redis
|
107
107
|
end
|
108
108
|
|
@@ -152,7 +152,7 @@ class SimpleThrottle
|
|
152
152
|
def current_size(push)
|
153
153
|
push_arg = (push ? 1 : 0)
|
154
154
|
time_ms = (Time.now.to_f * 1000).round
|
155
|
-
ttl_ms = ttl * 1000
|
155
|
+
ttl_ms = (ttl * 1000).ceil
|
156
156
|
self.class.send(:execute_lua_script, redis: redis_client, keys: [redis_key], args: [limit, ttl_ms, time_ms, push_arg])
|
157
157
|
end
|
158
158
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- We Heart It
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-09-
|
12
|
+
date: 2021-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|