kisyo 0.0.3 → 0.0.4

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: d8a99f62b8535e4a98f5852dfe53fafa38452f83
4
- data.tar.gz: 99a1477bb5740fcda0fea9b75b0434491ce70933
3
+ metadata.gz: eee1f14118949535141b098399c854e82e3570a6
4
+ data.tar.gz: f1f812d0c1f8944a77942a8b1b4a3d2065ab601a
5
5
  SHA512:
6
- metadata.gz: d8c8bb2db8af4f8950f4fb9c173df90b63d35bf931dc505e45aaa0eeba91bdc71e5805500ac64032f6e1c3f7519cfdd989e4455eedb7622563c7c8d482c73744
7
- data.tar.gz: 8a8e10cc74bd021ef9dc5921f8163447233d19f0e009a0ee91590ea5c92388a19432b0d55344aa0e5bc0f1532cb0b83bcdaab5a91ce5b92e8a746d90c048f2ed
6
+ metadata.gz: 39bd5a7b6948b839dc58bc27c7948156232b726eea9db503ce53a6ac82864dfa141a9474a5be859d42b6dcbc629deac5fe0a74d83508aa2090fa499d78947809
7
+ data.tar.gz: 881f405998cad23010907efed323a6ac6f57981de582b0c5403a37b4a217c17a57a13a706ad148049856e66877d5316822159a6e71a91e84927600023b6483fb
@@ -5,6 +5,7 @@ module Kisyo
5
5
  def initialize
6
6
  @keys = []
7
7
  @values = {}
8
+ @m = Mutex.new
8
9
  end
9
10
 
10
11
  def get(key)
@@ -12,17 +13,23 @@ module Kisyo
12
13
  end
13
14
 
14
15
  def set(key, value)
15
- keys << key
16
- values[key] = value
16
+ m.synchronize do
17
+ if values[key]
18
+ return
19
+ end
17
20
 
18
- if keys.size > CACHE_SIZE
19
- oldest_key = keys.shift
20
- values.delete(oldest_key)
21
+ keys << key
22
+ values[key] = value
23
+
24
+ if keys.size > CACHE_SIZE
25
+ oldest_key = keys.shift
26
+ values.delete(oldest_key)
27
+ end
21
28
  end
22
29
  end
23
30
 
24
31
  private
25
32
 
26
- attr_reader :keys, :values
33
+ attr_reader :keys, :values, :m
27
34
  end
28
35
  end
@@ -1,3 +1,3 @@
1
1
  module Kisyo
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kisyo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - youpy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri