wee 0.1.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALL +7 -0
- data/README +268 -0
- data/Rakefile +26 -0
- data/TODO +116 -0
- data/benchmark/Centrino1300/result.2000.counter.action +45 -0
- data/benchmark/Centrino1300/result.2000.counter.render +43 -0
- data/benchmark/Centrino1300/result.2000.filehandler +43 -0
- data/benchmark/Centrino600/result.2000.counter.action +47 -0
- data/benchmark/Centrino600/result.2000.counter.render +45 -0
- data/benchmark/Centrino600/result.2000.filehandler +43 -0
- data/benchmark/Makefile +48 -0
- data/benchmark/bench.sh +24 -0
- data/benchmark/counter.rb +96 -0
- data/benchmark/filehandler.rb +6 -0
- data/doc/rdoc/classes/Array.html +172 -0
- data/doc/rdoc/classes/Cache.html +126 -0
- data/doc/rdoc/classes/Cache/StorageCache.html +320 -0
- data/doc/rdoc/classes/Cache/Strategy.html +128 -0
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +269 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LFU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +238 -0
- data/doc/rdoc/classes/Cache/Strategy/LRU/Item.html +111 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +225 -0
- data/doc/rdoc/classes/Cache/Strategy/Unbounded/Item.html +111 -0
- data/doc/rdoc/classes/Enumerable.html +146 -0
- data/doc/rdoc/classes/LiteralMethod.html +196 -0
- data/doc/rdoc/classes/Object.html +178 -0
- data/doc/rdoc/classes/String.html +172 -0
- data/doc/rdoc/classes/Struct.html +174 -0
- data/doc/rdoc/classes/Wee.html +160 -0
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +182 -0
- data/doc/rdoc/classes/Wee/Application.html +337 -0
- data/doc/rdoc/classes/Wee/Brush.html +245 -0
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +157 -0
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +210 -0
- data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +141 -0
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +225 -0
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +283 -0
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +176 -0
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +195 -0
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +149 -0
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +172 -0
- data/doc/rdoc/classes/Wee/Brush/Page.html +193 -0
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +267 -0
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +177 -0
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +154 -0
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +173 -0
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +277 -0
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +146 -0
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +229 -0
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +154 -0
- data/doc/rdoc/classes/Wee/Callback.html +231 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +308 -0
- data/doc/rdoc/classes/Wee/CallbackStream.html +227 -0
- data/doc/rdoc/classes/Wee/Canvas.html +235 -0
- data/doc/rdoc/classes/Wee/Component.html +933 -0
- data/doc/rdoc/classes/Wee/Context.html +111 -0
- data/doc/rdoc/classes/Wee/Decoration.html +338 -0
- data/doc/rdoc/classes/Wee/Delegate.html +247 -0
- data/doc/rdoc/classes/Wee/ErrorPage.html +175 -0
- data/doc/rdoc/classes/Wee/ErrorResponse.html +180 -0
- data/doc/rdoc/classes/Wee/GenericResponse.html +162 -0
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +751 -0
- data/doc/rdoc/classes/Wee/HtmlWriter.html +351 -0
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +180 -0
- data/doc/rdoc/classes/Wee/MethodCallback.html +193 -0
- data/doc/rdoc/classes/Wee/Page.html +111 -0
- data/doc/rdoc/classes/Wee/Presenter.html +521 -0
- data/doc/rdoc/classes/Wee/RedirectResponse.html +150 -0
- data/doc/rdoc/classes/Wee/RefreshResponse.html +157 -0
- data/doc/rdoc/classes/Wee/RenderingContext.html +111 -0
- data/doc/rdoc/classes/Wee/Request.html +268 -0
- data/doc/rdoc/classes/Wee/RequestHandler.html +336 -0
- data/doc/rdoc/classes/Wee/Response.html +260 -0
- data/doc/rdoc/classes/Wee/Session.html +469 -0
- data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +198 -0
- data/doc/rdoc/classes/Wee/Snapshot.html +211 -0
- data/doc/rdoc/classes/Wee/StateHolder.html +149 -0
- data/doc/rdoc/classes/Wee/StateRegistry.html +434 -0
- data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +320 -0
- data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +153 -0
- data/doc/rdoc/classes/Wee/Utils.html +111 -0
- data/doc/rdoc/classes/Wee/Utils/LRUCache.html +148 -0
- data/doc/rdoc/classes/Wee/ValueHolder.html +220 -0
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +330 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/INSTALL.html +118 -0
- data/doc/rdoc/files/README.html +466 -0
- data/doc/rdoc/files/lib/cache/cache_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/application_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/callback_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/component_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/component_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/context_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +115 -0
- data/doc/rdoc/files/lib/wee/core/component_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/core/decoration_rb.html +133 -0
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/core_rb.html +131 -0
- data/doc/rdoc/files/lib/wee/decoration_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/holder_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/html_canvas_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/html_writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/idgen_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/page_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/presenter_rb.html +112 -0
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/request_rb.html +113 -0
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/response_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/session_rb.html +109 -0
- data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +101 -0
- data/doc/rdoc/files/lib/wee/snapshot_rb.html +107 -0
- data/doc/rdoc/files/lib/wee/state_registry_rb.html +110 -0
- data/doc/rdoc/files/lib/wee/stuff_rb.html +144 -0
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +108 -0
- data/doc/rdoc/files/lib/wee/webrick_rb.html +108 -0
- data/doc/rdoc/files/lib/wee_rb.html +132 -0
- data/doc/rdoc/fr_class_index.html +93 -0
- data/doc/rdoc/fr_file_index.html +51 -0
- data/doc/rdoc/fr_method_index.html +242 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/ObjectSpaceBrowser.rb +199 -0
- data/examples/calendar.rb +366 -0
- data/examples/cc.rb +94 -0
- data/examples/draw.rb +91 -0
- data/examples/example.rb +223 -0
- data/examples/test.rb +66 -0
- data/examples/window.rb +53 -0
- data/lib/cache/cache.rb +9 -0
- data/lib/wee.rb +18 -8
- data/lib/wee/adaptors/webrick.rb +73 -0
- data/lib/wee/application.rb +69 -71
- data/lib/wee/context.rb +2 -12
- data/lib/wee/core.rb +15 -0
- data/lib/wee/core/callback.rb +108 -0
- data/lib/wee/core/component.rb +314 -0
- data/lib/wee/core/decoration.rb +129 -0
- data/lib/wee/core/presenter.rb +132 -0
- data/lib/wee/core/snapshot.rb +21 -0
- data/lib/wee/core/valueholder.rb +19 -0
- data/lib/wee/idgen.rb +13 -0
- data/lib/wee/page.rb +1 -1
- data/lib/wee/renderer/html/brushes.rb +435 -0
- data/lib/wee/renderer/html/canvas.rb +148 -0
- data/lib/wee/{html_writer.rb → renderer/html/writer.rb} +31 -16
- data/lib/wee/request.rb +57 -0
- data/lib/wee/requesthandler.rb +77 -0
- data/lib/wee/response.rb +77 -0
- data/lib/wee/session.rb +70 -64
- data/lib/wee/{snapshot.rb → snapshot_ext.rb} +4 -4
- data/test/components/calltest.rb +16 -0
- data/test/components/counter.rb +17 -0
- data/test/components/messagebox.rb +15 -0
- data/test/components/page.rb +14 -0
- data/test/components/page_decoration.rb +7 -0
- data/test/stress.rb +64 -0
- data/test/test_component.rb +106 -0
- data/test/test_html_canvas.rb +25 -0
- data/test/test_html_writer.rb +27 -0
- data/test/test_request.rb +13 -0
- data/test/utils/cross.rb +65 -0
- data/test/utils/generic_plotter.rb +28 -0
- data/test/utils/gnuplot.rb +31 -0
- data/test/utils/measure_memory.rb +9 -0
- data/test/utils/memory_plotter.rb +10 -0
- data/test/utils/object_plotter.rb +10 -0
- data/test/utils/webrick_background.rb +31 -0
- data/wee.gemspec +22 -0
- metadata +222 -18
- data/lib/wee/component.rb +0 -126
- data/lib/wee/delegate_decoration.rb +0 -22
- data/lib/wee/handler_registry.rb +0 -89
- data/lib/wee/holder.rb +0 -14
- data/lib/wee/html_canvas.rb +0 -379
- data/lib/wee/state_registry.rb +0 -173
- data/lib/wee/stuff.rb +0 -29
- data/lib/wee/webrick.rb +0 -15
@@ -0,0 +1,269 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Cache::Strategy::CapacityBounded</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Cache::Strategy::CapacityBounded</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/cache/cache_rb.html">
|
59
|
+
lib/cache/cache.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="../Strategy.html">
|
69
|
+
Cache::Strategy
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
Abstract class for a capacity bounded strategy. Only up to
|
86
|
+
<em>capacity</em> items are allowed to be stored in the cache at any time.
|
87
|
+
</p>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
|
92
|
+
</div>
|
93
|
+
|
94
|
+
<div id="method-list">
|
95
|
+
<h3 class="section-bar">Methods</h3>
|
96
|
+
|
97
|
+
<div class="name-list">
|
98
|
+
<a href="#M000014">dec</a>
|
99
|
+
<a href="#M000016">empty?</a>
|
100
|
+
<a href="#M000015">full?</a>
|
101
|
+
<a href="#M000013">inc</a>
|
102
|
+
<a href="#M000012">new</a>
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
</div>
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if includes -->
|
110
|
+
|
111
|
+
<div id="section">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
<div id="attribute-list">
|
118
|
+
<h3 class="section-bar">Attributes</h3>
|
119
|
+
|
120
|
+
<div class="name-list">
|
121
|
+
<table>
|
122
|
+
<tr class="top-aligned-row context-row">
|
123
|
+
<td class="context-item-name">capacity</td>
|
124
|
+
<td class="context-item-value"> [RW] </td>
|
125
|
+
<td class="context-item-desc"></td>
|
126
|
+
</tr>
|
127
|
+
</table>
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<!-- if method_list -->
|
134
|
+
<div id="methods">
|
135
|
+
<h3 class="section-bar">Public Class methods</h3>
|
136
|
+
|
137
|
+
<div id="method-M000012" class="method-detail">
|
138
|
+
<a name="M000012"></a>
|
139
|
+
|
140
|
+
<div class="method-heading">
|
141
|
+
<a href="#M000012" class="method-signature">
|
142
|
+
<span class="method-name">new</span><span class="method-args">(capacity)</span>
|
143
|
+
</a>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
<div class="method-description">
|
147
|
+
<p><a class="source-toggle" href="#"
|
148
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
149
|
+
<div class="method-source-code" id="M000012-source">
|
150
|
+
<pre>
|
151
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 31</span>
|
152
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">capacity</span>)
|
153
|
+
<span class="ruby-ivar">@capacity</span> = <span class="ruby-identifier">capacity</span>
|
154
|
+
<span class="ruby-ivar">@n_items</span> = <span class="ruby-value">0</span> <span class="ruby-comment cmt"># number of items in cache</span>
|
155
|
+
<span class="ruby-keyword kw">end</span>
|
156
|
+
</pre>
|
157
|
+
</div>
|
158
|
+
</div>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
162
|
+
|
163
|
+
<div id="method-M000014" class="method-detail">
|
164
|
+
<a name="M000014"></a>
|
165
|
+
|
166
|
+
<div class="method-heading">
|
167
|
+
<a href="#M000014" class="method-signature">
|
168
|
+
<span class="method-name">dec</span><span class="method-args">(item)</span>
|
169
|
+
</a>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<div class="method-description">
|
173
|
+
<p><a class="source-toggle" href="#"
|
174
|
+
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
175
|
+
<div class="method-source-code" id="M000014-source">
|
176
|
+
<pre>
|
177
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 41</span>
|
178
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dec</span>(<span class="ruby-identifier">item</span>)
|
179
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">empty?</span>
|
180
|
+
<span class="ruby-ivar">@n_items</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
|
181
|
+
<span class="ruby-keyword kw">end</span>
|
182
|
+
</pre>
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
</div>
|
186
|
+
|
187
|
+
<div id="method-M000016" class="method-detail">
|
188
|
+
<a name="M000016"></a>
|
189
|
+
|
190
|
+
<div class="method-heading">
|
191
|
+
<a href="#M000016" class="method-signature">
|
192
|
+
<span class="method-name">empty?</span><span class="method-args">()</span>
|
193
|
+
</a>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
<p><a class="source-toggle" href="#"
|
198
|
+
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
199
|
+
<div class="method-source-code" id="M000016-source">
|
200
|
+
<pre>
|
201
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 50</span>
|
202
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty?</span>
|
203
|
+
<span class="ruby-ivar">@n_items</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
204
|
+
<span class="ruby-keyword kw">end</span>
|
205
|
+
</pre>
|
206
|
+
</div>
|
207
|
+
</div>
|
208
|
+
</div>
|
209
|
+
|
210
|
+
<div id="method-M000015" class="method-detail">
|
211
|
+
<a name="M000015"></a>
|
212
|
+
|
213
|
+
<div class="method-heading">
|
214
|
+
<a href="#M000015" class="method-signature">
|
215
|
+
<span class="method-name">full?</span><span class="method-args">()</span>
|
216
|
+
</a>
|
217
|
+
</div>
|
218
|
+
|
219
|
+
<div class="method-description">
|
220
|
+
<p><a class="source-toggle" href="#"
|
221
|
+
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
222
|
+
<div class="method-source-code" id="M000015-source">
|
223
|
+
<pre>
|
224
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 46</span>
|
225
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">full?</span>
|
226
|
+
<span class="ruby-ivar">@n_items</span> <span class="ruby-operator">>=</span> <span class="ruby-ivar">@capacity</span>
|
227
|
+
<span class="ruby-keyword kw">end</span>
|
228
|
+
</pre>
|
229
|
+
</div>
|
230
|
+
</div>
|
231
|
+
</div>
|
232
|
+
|
233
|
+
<div id="method-M000013" class="method-detail">
|
234
|
+
<a name="M000013"></a>
|
235
|
+
|
236
|
+
<div class="method-heading">
|
237
|
+
<a href="#M000013" class="method-signature">
|
238
|
+
<span class="method-name">inc</span><span class="method-args">(item)</span>
|
239
|
+
</a>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
<div class="method-description">
|
243
|
+
<p><a class="source-toggle" href="#"
|
244
|
+
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
245
|
+
<div class="method-source-code" id="M000013-source">
|
246
|
+
<pre>
|
247
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 36</span>
|
248
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inc</span>(<span class="ruby-identifier">item</span>)
|
249
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">full?</span>
|
250
|
+
<span class="ruby-ivar">@n_items</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
251
|
+
<span class="ruby-keyword kw">end</span>
|
252
|
+
</pre>
|
253
|
+
</div>
|
254
|
+
</div>
|
255
|
+
</div>
|
256
|
+
|
257
|
+
|
258
|
+
</div>
|
259
|
+
|
260
|
+
|
261
|
+
</div>
|
262
|
+
|
263
|
+
|
264
|
+
<div id="validator-badges">
|
265
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
266
|
+
</div>
|
267
|
+
|
268
|
+
</body>
|
269
|
+
</html>
|
@@ -0,0 +1,238 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Cache::Strategy::LFU</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Cache::Strategy::LFU</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/cache/cache_rb.html">
|
59
|
+
lib/cache/cache.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
<a href="CapacityBounded.html">
|
69
|
+
Cache::Strategy::CapacityBounded
|
70
|
+
</a>
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
</table>
|
74
|
+
</div>
|
75
|
+
<!-- banner header -->
|
76
|
+
|
77
|
+
<div id="bodyContent">
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<div id="contextContent">
|
82
|
+
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
Implements the least frequently used (<a href="LFU.html">LFU</a>) strategy.
|
86
|
+
</p>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<div id="method-list">
|
94
|
+
<h3 class="section-bar">Methods</h3>
|
95
|
+
|
96
|
+
<div class="name-list">
|
97
|
+
<a href="#M000022">access</a>
|
98
|
+
<a href="#M000023">delete</a>
|
99
|
+
<a href="#M000024">insert_or_extrude</a>
|
100
|
+
<a href="#M000021">item_class</a>
|
101
|
+
</div>
|
102
|
+
</div>
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
|
107
|
+
<!-- if includes -->
|
108
|
+
|
109
|
+
<div id="section">
|
110
|
+
|
111
|
+
<div id="class-list">
|
112
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
113
|
+
|
114
|
+
Class <a href="LFU/Item.html" class="link">Cache::Strategy::LFU::Item</a><br />
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<!-- if method_list -->
|
125
|
+
<div id="methods">
|
126
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
127
|
+
|
128
|
+
<div id="method-M000022" class="method-detail">
|
129
|
+
<a name="M000022"></a>
|
130
|
+
|
131
|
+
<div class="method-heading">
|
132
|
+
<a href="#M000022" class="method-signature">
|
133
|
+
<span class="method-name">access</span><span class="method-args">(item)</span>
|
134
|
+
</a>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<div class="method-description">
|
138
|
+
<p><a class="source-toggle" href="#"
|
139
|
+
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
140
|
+
<div class="method-source-code" id="M000022-source">
|
141
|
+
<pre>
|
142
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 60</span>
|
143
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">access</span>(<span class="ruby-identifier">item</span>)
|
144
|
+
<span class="ruby-identifier">item</span>.<span class="ruby-identifier">freq</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
145
|
+
<span class="ruby-keyword kw">end</span>
|
146
|
+
</pre>
|
147
|
+
</div>
|
148
|
+
</div>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div id="method-M000023" class="method-detail">
|
152
|
+
<a name="M000023"></a>
|
153
|
+
|
154
|
+
<div class="method-heading">
|
155
|
+
<a href="#M000023" class="method-signature">
|
156
|
+
<span class="method-name">delete</span><span class="method-args">(item)</span>
|
157
|
+
</a>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
<p><a class="source-toggle" href="#"
|
162
|
+
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
163
|
+
<div class="method-source-code" id="M000023-source">
|
164
|
+
<pre>
|
165
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 64</span>
|
166
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">item</span>)
|
167
|
+
<span class="ruby-identifier">dec</span>(<span class="ruby-identifier">item</span>)
|
168
|
+
<span class="ruby-keyword kw">end</span>
|
169
|
+
</pre>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<div id="method-M000024" class="method-detail">
|
175
|
+
<a name="M000024"></a>
|
176
|
+
|
177
|
+
<div class="method-heading">
|
178
|
+
<a href="#M000024" class="method-signature">
|
179
|
+
<span class="method-name">insert_or_extrude</span><span class="method-args">(item, enum) {|enum.min_by {|key, it| it.freq| ...}</span>
|
180
|
+
</a>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
<div class="method-description">
|
184
|
+
<table>
|
185
|
+
<tr><td valign="top">enum:</td><td>a [key, item] enumerable
|
186
|
+
|
187
|
+
</td></tr>
|
188
|
+
</table>
|
189
|
+
<p><a class="source-toggle" href="#"
|
190
|
+
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
191
|
+
<div class="method-source-code" id="M000024-source">
|
192
|
+
<pre>
|
193
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 71</span>
|
194
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert_or_extrude</span>(<span class="ruby-identifier">item</span>, <span class="ruby-identifier">enum</span>)
|
195
|
+
<span class="ruby-comment cmt"># find least recently used key/item and yield</span>
|
196
|
+
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">min_by</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">it</span><span class="ruby-operator">|</span> <span class="ruby-identifier">it</span>.<span class="ruby-identifier">freq</span>} <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">full?</span>
|
197
|
+
<span class="ruby-identifier">item</span>.<span class="ruby-identifier">freq</span> = <span class="ruby-value">0</span>
|
198
|
+
<span class="ruby-identifier">inc</span>(<span class="ruby-identifier">item</span>)
|
199
|
+
<span class="ruby-keyword kw">end</span>
|
200
|
+
</pre>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<div id="method-M000021" class="method-detail">
|
206
|
+
<a name="M000021"></a>
|
207
|
+
|
208
|
+
<div class="method-heading">
|
209
|
+
<a href="#M000021" class="method-signature">
|
210
|
+
<span class="method-name">item_class</span><span class="method-args">()</span>
|
211
|
+
</a>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
<div class="method-description">
|
215
|
+
<p><a class="source-toggle" href="#"
|
216
|
+
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
217
|
+
<div class="method-source-code" id="M000021-source">
|
218
|
+
<pre>
|
219
|
+
<span class="ruby-comment cmt"># File lib/cache/cache.rb, line 58</span>
|
220
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">item_class</span>() <span class="ruby-constant">Item</span> <span class="ruby-keyword kw">end</span>
|
221
|
+
</pre>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
</div>
|
225
|
+
|
226
|
+
|
227
|
+
</div>
|
228
|
+
|
229
|
+
|
230
|
+
</div>
|
231
|
+
|
232
|
+
|
233
|
+
<div id="validator-badges">
|
234
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
235
|
+
</div>
|
236
|
+
|
237
|
+
</body>
|
238
|
+
</html>
|