1 |
=begin |
=begin |
2 |
= Ruby/Cache 0.1 |
= Ruby/Cache 0.2 |
3 |
== What is Ruby/Cache |
== What is Ruby/Cache |
4 |
|
|
5 |
Ruby/Cache is a library for caching objects based on the LRU algorithm |
Ruby/Cache is a library for caching objects based on the LRU algorithm |
6 |
for Ruby. The official page is |
for Ruby. The official page is |
7 |
((<URL:http://www.freesoftware.fsf.org/pupa/ruby-cache.html>)). |
((<URL:http://www.nongnu.org/pupa/ruby-cache.html>)). |
8 |
|
|
9 |
== How to install |
== How to install |
10 |
|
|
16 |
|
|
17 |
Here is a simple usage: |
Here is a simple usage: |
18 |
|
|
19 |
|
require 'cache' |
20 |
|
|
21 |
cache = Cache.new |
cache = Cache.new |
22 |
cache['foo'] = 'bar' |
cache['foo'] = 'bar' |
23 |
p cache['foo'] |
p cache['foo'] |
38 |
while true |
while true |
39 |
puts 'Input an integer: ' |
puts 'Input an integer: ' |
40 |
i = gets.to_i |
i = gets.to_i |
41 |
unless cache.cached?(i) |
puts cache.fetch(i) { generate_prime_greater_than(i) } |
|
cache[i] = generate_prime_greater_than(i) |
|
|
end |
|
|
puts cache[i] |
|
42 |
end |
end |
43 |
|
|
|
== Reference |
|
|
|
|
|
Not written yet. |
|
|
|
|
44 |
== License |
== License |
45 |
|
|
46 |
You may redistribute it and/or modify it under the same term as Ruby's. |
You may redistribute it and/or modify it under the same term as Ruby's. |