hiera-router 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiera/backend/router_backend.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90751f504280dac34446f8828a953231c32797cb
|
4
|
+
data.tar.gz: ff992a9564ae7735fafc05dc7798a20616ebb3c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df859f645d6dc5c46cd2d430e641b04170bcf41d2733340ff04885013a2c4d6d0e4a4eac3d66cb77e60743b0576af93e9b9d5862fd92cd4aeb72626c84ea962
|
7
|
+
data.tar.gz: bd0bd5d0b02242f0c69b6db42d43348b86bf401433ba6cf9e6cf41f5c41524324ca78d495443357b3359f3b9cadbd4f667ef778f8bdf1a1758599d9a26152e09
|
@@ -21,7 +21,9 @@ class Hiera
|
|
21
21
|
|
22
22
|
def initialize(cache = nil)
|
23
23
|
@cache = cache || Filecache.new
|
24
|
+
@bigcache = {}
|
24
25
|
@backends = {}
|
26
|
+
@cache = 60 # Cache all values for 1 minute
|
25
27
|
Hiera.debug("[hiera-router] I'm here!")
|
26
28
|
self.config = Config.config
|
27
29
|
|
@@ -66,6 +68,12 @@ class Hiera
|
|
66
68
|
:order_override => order_override,
|
67
69
|
:resolution_type => resolution_type,
|
68
70
|
}
|
71
|
+
|
72
|
+
cache_key = options.to_s
|
73
|
+
cached_value = @bigcache[cache_key]
|
74
|
+
if cached_value
|
75
|
+
return cached_value[:value] if cached_value[:time] > Time.now - @cache
|
76
|
+
end
|
69
77
|
answer = nil
|
70
78
|
|
71
79
|
Hiera.debug("[hiera-router] Looking up #{key} in yaml backend")
|
@@ -106,6 +114,10 @@ class Hiera
|
|
106
114
|
end
|
107
115
|
end
|
108
116
|
|
117
|
+
@bigcache[cache_key] = {
|
118
|
+
:value => answer,
|
119
|
+
:time => Time.now,
|
120
|
+
}
|
109
121
|
return answer
|
110
122
|
end
|
111
123
|
|