fifo-cache 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +37 -37
- data/LICENSE.txt +1 -2
- data/README.md +24 -30
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/fifo-cache.gemspec +8 -10
- data/lib/fifocache.rb +3 -5
- data/test +6 -7
- metadata +16 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a984c0e92c7e6056b233c82e00a714ec8fa7f468
|
4
|
+
data.tar.gz: e1a97f47decbc910a4d878b93735e6b3591ba501
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32c2f2b81fa9fe64cab34640cfd25ca149182b1f6378d0c237501ead5a4f2668aeb4b69c62fc5ce118c962a446e1205079f7dace3b75ea36f240f909dfca3936
|
7
|
+
data.tar.gz: f1a5a30752fc568ccdf5e1321eee4d2abe0c8c4114c8f67c5864097ff72bd3deeda57ca285aa69c9ea48d9202f5ff6a0555e6a4bb5fe365ec6205ee7650f95e1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,52 +1,50 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
4
|
+
addressable (2.3.8)
|
5
5
|
builder (3.2.2)
|
6
|
-
depq (0.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
depq (0.7)
|
7
|
+
descendants_tracker (0.0.4)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
9
|
+
faraday (0.9.1)
|
10
|
+
multipart-post (>= 1.2, < 3)
|
11
|
+
git (1.2.9.1)
|
12
|
+
github_api (0.12.3)
|
13
|
+
addressable (~> 2.3)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
faraday (~> 0.8, < 0.10)
|
16
|
+
hashie (>= 3.3)
|
17
|
+
multi_json (>= 1.7.5, < 2.0)
|
18
|
+
nokogiri (~> 1.6.3)
|
16
19
|
oauth2
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
highline (1.6.19)
|
21
|
-
httpauth (0.2.0)
|
22
|
-
jeweler (1.8.8)
|
20
|
+
hashie (3.4.2)
|
21
|
+
highline (1.7.2)
|
22
|
+
jeweler (2.0.1)
|
23
23
|
builder
|
24
|
-
bundler (
|
24
|
+
bundler (>= 1.0)
|
25
25
|
git (>= 1.2.5)
|
26
|
-
github_api
|
26
|
+
github_api
|
27
27
|
highline (>= 1.6.15)
|
28
|
-
nokogiri (
|
28
|
+
nokogiri (>= 1.5.10)
|
29
29
|
rake
|
30
30
|
rdoc
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
multi_json (1.8.2)
|
31
|
+
jwt (1.5.1)
|
32
|
+
mini_portile (0.6.2)
|
33
|
+
multi_json (1.11.2)
|
35
34
|
multi_xml (0.5.5)
|
36
|
-
multipart-post (
|
37
|
-
nokogiri (1.
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
jwt (~>
|
42
|
-
multi_json (~> 1.
|
35
|
+
multipart-post (2.0.0)
|
36
|
+
nokogiri (1.6.6.2)
|
37
|
+
mini_portile (~> 0.6.0)
|
38
|
+
oauth2 (1.0.0)
|
39
|
+
faraday (>= 0.8, < 0.10)
|
40
|
+
jwt (~> 1.0)
|
41
|
+
multi_json (~> 1.3)
|
43
42
|
multi_xml (~> 0.5)
|
44
43
|
rack (~> 1.2)
|
45
|
-
rack (1.
|
46
|
-
rake (10.
|
47
|
-
rdoc (4.0
|
48
|
-
|
49
|
-
ruby-version (0.4.3)
|
44
|
+
rack (1.6.4)
|
45
|
+
rake (10.4.2)
|
46
|
+
rdoc (4.2.0)
|
47
|
+
thread_safe (0.3.5)
|
50
48
|
|
51
49
|
PLATFORMS
|
52
50
|
ruby
|
@@ -54,5 +52,7 @@ PLATFORMS
|
|
54
52
|
DEPENDENCIES
|
55
53
|
bundler (>= 1.0.0)
|
56
54
|
depq (>= 0.4)
|
57
|
-
hash-utils (>= 0.7.0)
|
58
55
|
jeweler (>= 1.5.2)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
1.10.5
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Copyright (c) 2010 -
|
2
|
-
(c) 2013 Martin Poljak (martin@poljak.cz)
|
1
|
+
Copyright (c) 2010 - 2015 Martin Poljak (martin@poljak.cz)
|
3
2
|
|
4
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
5
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -23,28 +23,34 @@ higher than 1 according dynamics of your application.
|
|
23
23
|
|
24
24
|
Usage is simple (examples here are for demonstration purposes written
|
25
25
|
without factor set):
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require "fifocache"
|
29
|
+
|
30
|
+
cache = Fifocache::new(3, :puts => true) # or 300000, od sure :-)
|
31
|
+
cache[:alfa] = 'alfa'
|
32
|
+
cache[:beta] = 'beta'
|
33
|
+
cache[:gama] = 'gama'
|
34
|
+
cache[:delta] = 'delta' # in this moment, :alfa is removed
|
35
|
+
```
|
34
36
|
|
35
37
|
But multiple addings are tracked, so subsequent call:
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
```ruby
|
40
|
+
cache[:beta] = 'beta' # :beta, :gama, :delta in cache
|
41
|
+
cache[:alfa] = 'alfa' # :beta, :delta, :alfa in cache
|
42
|
+
```
|
43
|
+
|
40
44
|
…will cause `:gama` will be removed, not `:beta` because `:beta` is
|
41
45
|
fresher now. If hits tracking is turned on:
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
```ruby
|
48
|
+
cache.hits = true # you can do it in constructor too
|
49
|
+
|
50
|
+
puts cache[:delta] # cache hit
|
51
|
+
cache[:gama] = 'gama' # :beta, :delta, :gama in cache
|
52
|
+
```
|
53
|
+
|
48
54
|
…because `:beta` has been put-in two times, `:delta` has been hit
|
49
55
|
recently, so `:alfa` is less accessed row and has been removed. In case
|
50
56
|
of hits tracking turned off, `:delta` would be removed of sure and
|
@@ -55,24 +61,12 @@ is generally rather slow because of necessity to remove all redundant
|
|
55
61
|
"oldest" rows.
|
56
62
|
|
57
63
|
|
58
|
-
Contributing
|
59
|
-
------------
|
60
|
-
|
61
|
-
1. Fork it.
|
62
|
-
2. Create a branch (`git checkout -b 20101220-my-change`).
|
63
|
-
3. Commit your changes (`git commit -am "Added something"`).
|
64
|
-
4. Push to the branch (`git push origin 20101220-my-change`).
|
65
|
-
5. Create an [Issue][2] with a link to your branch.
|
66
|
-
6. Enjoy a refreshing Diet Coke and wait.
|
67
|
-
|
68
|
-
|
69
64
|
Copyright
|
70
65
|
---------
|
71
66
|
|
72
|
-
Copyright © 2010
|
67
|
+
Copyright © 2010 – 2015 [Martin Poljak][3].
|
73
68
|
See `LICENSE.txt` for further details.
|
74
69
|
|
75
70
|
[1]: http://www.cs.princeton.edu/courses/archive/spr09/cos423/Lectures/i-heaps.pdf
|
76
71
|
[2]: http://github.com/martinkozak/fifo-cache/issues
|
77
|
-
[3]: http://www.
|
78
|
-
[4]: http://www.martinpoljak.net/
|
72
|
+
[3]: http://www.martinpoljak.net/
|
data/Rakefile
CHANGED
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
|
17
17
|
gem.homepage = "http://github.com/martinkozak/fifo-cache"
|
18
18
|
gem.license = "MIT"
|
19
19
|
gem.summary = 'Fast hash-like fixed size cache class with FIFO functionality which removes oldest or less accessed records based on implicit heap.'
|
20
|
-
gem.email = "
|
21
|
-
gem.authors = ["Martin
|
20
|
+
gem.email = "martin@poljak.cz"
|
21
|
+
gem.authors = ["Martin Poljak"]
|
22
22
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
23
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
24
|
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/fifo-cache.gemspec
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: fifo-cache 0.1.2 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "fifo-cache"
|
8
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.2"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Martin Poljak"]
|
14
|
+
s.date = "2015-07-19"
|
15
|
+
s.email = "martin@poljak.cz"
|
14
16
|
s.extra_rdoc_files = [
|
15
17
|
"LICENSE.txt",
|
16
18
|
"README.md"
|
@@ -29,27 +31,23 @@ Gem::Specification.new do |s|
|
|
29
31
|
]
|
30
32
|
s.homepage = "http://github.com/martinkozak/fifo-cache"
|
31
33
|
s.licenses = ["MIT"]
|
32
|
-
s.
|
33
|
-
s.rubygems_version = "1.8.25"
|
34
|
+
s.rubygems_version = "2.4.5"
|
34
35
|
s.summary = "Fast hash-like fixed size cache class with FIFO functionality which removes oldest or less accessed records based on implicit heap."
|
35
36
|
|
36
37
|
if s.respond_to? :specification_version then
|
37
|
-
s.specification_version =
|
38
|
+
s.specification_version = 4
|
38
39
|
|
39
40
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
41
|
s.add_runtime_dependency(%q<depq>, [">= 0.4"])
|
41
|
-
s.add_runtime_dependency(%q<hash-utils>, [">= 0.7.0"])
|
42
42
|
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
43
43
|
s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
|
44
44
|
else
|
45
45
|
s.add_dependency(%q<depq>, [">= 0.4"])
|
46
|
-
s.add_dependency(%q<hash-utils>, [">= 0.7.0"])
|
47
46
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
48
47
|
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
49
48
|
end
|
50
49
|
else
|
51
50
|
s.add_dependency(%q<depq>, [">= 0.4"])
|
52
|
-
s.add_dependency(%q<hash-utils>, [">= 0.7.0"])
|
53
51
|
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
54
52
|
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
55
53
|
end
|
data/lib/fifocache.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
# (c) 2010-
|
3
|
-
# (c) 2013 Martin Poljak (martin@poljak.cz)
|
2
|
+
# (c) 2010 - 2015 Martin Poljak (martin@poljak.cz)
|
4
3
|
|
5
|
-
require "hash-utils/object"
|
6
4
|
require "depq"
|
7
5
|
|
8
6
|
##
|
@@ -82,8 +80,8 @@ class Fifocache
|
|
82
80
|
@counts = { }
|
83
81
|
|
84
82
|
@size = size
|
85
|
-
@puts = opts[:puts]
|
86
|
-
@hits = opts[:hits]
|
83
|
+
@puts = !!opts[:puts]
|
84
|
+
@hits = !!opts[:hits]
|
87
85
|
@factor = opts[:factor].to_f
|
88
86
|
end
|
89
87
|
|
data/test
CHANGED
@@ -5,12 +5,12 @@ $:.push("./lib")
|
|
5
5
|
require "fifocache"
|
6
6
|
|
7
7
|
|
8
|
-
cache = Fifocache::new(100000, :puts => false, :factor => 0)
|
9
|
-
200000.times do |i|
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
exit
|
8
|
+
# cache = Fifocache::new(100000, :puts => false, :factor => 0)
|
9
|
+
# 200000.times do |i|
|
10
|
+
# cache[i] = i
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# exit
|
14
14
|
|
15
15
|
cache = Fifocache::new(3, :puts => true)
|
16
16
|
cache[:alfa] = 'alfa'
|
@@ -34,4 +34,3 @@ puts cache.to_h.inspect
|
|
34
34
|
cache.resize(0)
|
35
35
|
|
36
36
|
puts cache.to_h.inspect
|
37
|
-
|
metadata
CHANGED
@@ -1,89 +1,66 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fifo-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
- Martin
|
7
|
+
- Martin Poljak
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-07-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: depq
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0.4'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0.4'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: hash-utils
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.7.0
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.7.0
|
46
27
|
- !ruby/object:Gem::Dependency
|
47
28
|
name: bundler
|
48
29
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
30
|
requirements:
|
51
|
-
- -
|
31
|
+
- - ">="
|
52
32
|
- !ruby/object:Gem::Version
|
53
33
|
version: 1.0.0
|
54
34
|
type: :development
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
37
|
requirements:
|
59
|
-
- -
|
38
|
+
- - ">="
|
60
39
|
- !ruby/object:Gem::Version
|
61
40
|
version: 1.0.0
|
62
41
|
- !ruby/object:Gem::Dependency
|
63
42
|
name: jeweler
|
64
43
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
44
|
requirements:
|
67
|
-
- -
|
45
|
+
- - ">="
|
68
46
|
- !ruby/object:Gem::Version
|
69
47
|
version: 1.5.2
|
70
48
|
type: :development
|
71
49
|
prerelease: false
|
72
50
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
51
|
requirements:
|
75
|
-
- -
|
52
|
+
- - ">="
|
76
53
|
- !ruby/object:Gem::Version
|
77
54
|
version: 1.5.2
|
78
55
|
description:
|
79
|
-
email:
|
56
|
+
email: martin@poljak.cz
|
80
57
|
executables: []
|
81
58
|
extensions: []
|
82
59
|
extra_rdoc_files:
|
83
60
|
- LICENSE.txt
|
84
61
|
- README.md
|
85
62
|
files:
|
86
|
-
- .document
|
63
|
+
- ".document"
|
87
64
|
- Gemfile
|
88
65
|
- Gemfile.lock
|
89
66
|
- LICENSE.txt
|
@@ -96,30 +73,26 @@ files:
|
|
96
73
|
homepage: http://github.com/martinkozak/fifo-cache
|
97
74
|
licenses:
|
98
75
|
- MIT
|
76
|
+
metadata: {}
|
99
77
|
post_install_message:
|
100
78
|
rdoc_options: []
|
101
79
|
require_paths:
|
102
80
|
- lib
|
103
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
82
|
requirements:
|
106
|
-
- -
|
83
|
+
- - ">="
|
107
84
|
- !ruby/object:Gem::Version
|
108
85
|
version: '0'
|
109
|
-
segments:
|
110
|
-
- 0
|
111
|
-
hash: -2442560149070771212
|
112
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
87
|
requirements:
|
115
|
-
- -
|
88
|
+
- - ">="
|
116
89
|
- !ruby/object:Gem::Version
|
117
90
|
version: '0'
|
118
91
|
requirements: []
|
119
92
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.4.5
|
121
94
|
signing_key:
|
122
|
-
specification_version:
|
95
|
+
specification_version: 4
|
123
96
|
summary: Fast hash-like fixed size cache class with FIFO functionality which removes
|
124
97
|
oldest or less accessed records based on implicit heap.
|
125
98
|
test_files: []
|