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 +4 -4
- data/lib/kisyo/cache.rb +13 -6
- data/lib/kisyo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eee1f14118949535141b098399c854e82e3570a6
|
4
|
+
data.tar.gz: f1f812d0c1f8944a77942a8b1b4a3d2065ab601a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39bd5a7b6948b839dc58bc27c7948156232b726eea9db503ce53a6ac82864dfa141a9474a5be859d42b6dcbc629deac5fe0a74d83508aa2090fa499d78947809
|
7
|
+
data.tar.gz: 881f405998cad23010907efed323a6ac6f57981de582b0c5403a37b4a217c17a57a13a706ad148049856e66877d5316822159a6e71a91e84927600023b6483fb
|
data/lib/kisyo/cache.rb
CHANGED
@@ -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
|
-
|
16
|
-
|
16
|
+
m.synchronize do
|
17
|
+
if values[key]
|
18
|
+
return
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
data/lib/kisyo/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|