sequel-rack_throttle 0.0.7
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 +7 -0
- data/lib/sequel-rack_throttle/Database.rb +30 -0
- data/lib/sequel-rack_throttle.rb +1 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 85fbd1c58534479f770bb201a179f68b88563e1f
|
4
|
+
data.tar.gz: ae2a3c575dfb707c8bb762a2fc589359dcce75a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7432e5e835760e2f90269c0038fab7d8240ad33286ac5ef01829e74bb2bb8bbafbd02150f6c96927ef3326d569b790b1639373290a69c31c68beb4582ff8e7e3
|
7
|
+
data.tar.gz: ab55129f21ef08f291388fc524aae365b077ded054582fd785a0cfa64fed04e143d6ad538abfaa07c8ff379f9edca9b48aac48f9f5ed962c0d2243f27fed1158
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
|
3
|
+
module Sequel
|
4
|
+
module MySQL
|
5
|
+
class Database < Sequel::Database
|
6
|
+
alias_method :old_init, :initialize
|
7
|
+
|
8
|
+
def initialize(args)
|
9
|
+
old_init(args)
|
10
|
+
|
11
|
+
create_table? :throttle_cache do
|
12
|
+
String :key, primary_key: true
|
13
|
+
Float :value, default: 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def cache_dataset
|
18
|
+
self[:throttle_cache]
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(key)
|
22
|
+
(cache_dataset.filter(key: key).first[:value].to_f)
|
23
|
+
end
|
24
|
+
|
25
|
+
def set(key, value)
|
26
|
+
unless cache_dataset.where(key: key).update(value: value) == 1 then cache_dataset.insert(key: key, value: value) end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'sequel-rack_throttle/Database'
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sequel-rack_throttle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gergely Borsothy-Gaal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sequel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.31'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.31'
|
27
|
+
description: Sequel patch so you can plug any Sequel-supported database under rack-throttle
|
28
|
+
as a counter.
|
29
|
+
email: bggergo@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/sequel-rack_throttle.rb
|
35
|
+
- lib/sequel-rack_throttle/Database.rb
|
36
|
+
homepage: https://github.com/gergelyborsothy/sequel-rack_throttle
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.9.0
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.4.5.1
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Sequel class patch to work with rake-throttle
|
60
|
+
test_files: []
|
61
|
+
has_rdoc:
|