execache 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/execache.gemspec +1 -1
- data/lib/execache.rb +24 -19
- metadata +8 -8
data/execache.gemspec
CHANGED
data/lib/execache.rb
CHANGED
@@ -69,29 +69,34 @@ class Execache
|
|
69
69
|
|
70
70
|
if pending
|
71
71
|
# Execute command in thread, cache results
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
72
|
+
unless redis.get('execache:wait')
|
73
|
+
Thread.new do
|
74
|
+
Timeout.timeout(60) do
|
75
|
+
redis.set('execache:wait', '1')
|
76
|
+
redis.expire('execache:wait', 120)
|
77
|
+
request.each do |cmd_type, cmd_options|
|
78
|
+
if cmd_options['cmd']
|
79
|
+
separators = options[cmd_type]['separators'] || {}
|
80
|
+
separators['group'] ||= "[END]"
|
81
|
+
separators['result'] ||= "\n"
|
82
|
+
output = `#{cmd_options['cmd']}`
|
83
|
+
output = output.split(separators['group'] + separators['result'])
|
84
|
+
output = output.collect { |r| r.split(separators['result']) }
|
85
|
+
end
|
83
86
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
cmd_options['groups'].each do |group|
|
88
|
+
unless group['result']
|
89
|
+
redis.set(
|
90
|
+
group['cache_key'],
|
91
|
+
Yajl::Encoder.encode(output.shift)
|
92
|
+
)
|
93
|
+
if group['ttl']
|
94
|
+
redis.expire(group['cache_key'], group['ttl'])
|
95
|
+
end
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
99
|
+
redis.del('execache:wait')
|
95
100
|
end
|
96
101
|
end
|
97
102
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: execache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-18 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70180953040920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70180953040920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis
|
27
|
-
requirement: &
|
27
|
+
requirement: &70180953040440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.2.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70180953040440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: yajl-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &70180953039980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70180953039980
|
47
47
|
description: Run commands in parallel and cache the output. Redis queues jobs and
|
48
48
|
stores the result.
|
49
49
|
email:
|