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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff0de745bf34c2ba0c0c71b47cb3f8efc2b071ed
4
- data.tar.gz: bad9cc3c4069c7245d8f158b40166c66501f56dd
3
+ metadata.gz: 90751f504280dac34446f8828a953231c32797cb
4
+ data.tar.gz: ff992a9564ae7735fafc05dc7798a20616ebb3c6
5
5
  SHA512:
6
- metadata.gz: c0967920ccbc41e82df153f8d697bcd5959578dfad2640b10ffd89a65f7fb7bfab0c23f88c588eb01b637dd636a123764078f36e2eaf7e6a4aa75b9711aa3a2d
7
- data.tar.gz: 61686a983f9440f58bd508cd7e2e90efb608d9a4749aebf0435bcdfaf28e03219b970172aacf7445d05c33e4caf3e298605e7e913db13f684385216ffffd7bd6
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Vandeginste