unicache 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/doc/UniCache.html CHANGED
@@ -96,7 +96,9 @@
96
96
 
97
97
 
98
98
  <dt class="r2 last">Defined in:</dt>
99
- <dd class="r2 last">lib/unicache.rb</dd>
99
+ <dd class="r2 last">lib/unicache.rb<span class="defines">,<br />
100
+ lib/version.rb</span>
101
+ </dd>
100
102
 
101
103
  </dl>
102
104
  <div class="clear"></div>
@@ -104,15 +106,17 @@
104
106
  <h2>Overview</h2><div class="docstring">
105
107
  <div class="discussion">
106
108
 
107
- <p>UniCache is Universal purpose Cache with Least Recently Used replacement
109
+ <p><span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> is Universal purpose Cache with Least Recently Used replacement
108
110
  policy by default. Cache can be configured with another policy.</p>
109
111
 
110
- <p>UniCache is intended to be Thread safe.</p>
112
+ <p><span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> is intended to be Thread safe.</p>
111
113
 
112
- <p>User can register callbacks that are run at various UniCache events.
114
+ <p>User can register callbacks that are run at various <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> events.
113
115
  ":getdata" callback is used to retreive cache data if not in cache. Others
114
116
  do not effect the UniCache state.</p>
115
117
 
118
+ <p>UniCache is inherits Hash, i.e. almost all Hash methods are usable.</p>
119
+
116
120
  <p>Usage example:</p>
117
121
 
118
122
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>unicache</span><span class='tstring_end'>'</span></span>
@@ -161,6 +165,18 @@ Miss: 2:&lt;NA&gt;</code></pre>
161
165
 
162
166
  </p>
163
167
 
168
+ <h2>Constant Summary</h2>
169
+
170
+ <dl class="constants">
171
+
172
+ <dt id="VERSION-constant" class="">VERSION =
173
+
174
+ </dt>
175
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.0.3</span><span class='tstring_end'>&quot;</span></span></pre></dd>
176
+
177
+ </dl>
178
+
179
+
164
180
 
165
181
 
166
182
 
@@ -231,6 +247,37 @@ Miss: 2:&lt;NA&gt;</code></pre>
231
247
 
232
248
 
233
249
 
250
+ <h2>
251
+ Class Method Summary
252
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
253
+ </h2>
254
+
255
+ <ul class="summary">
256
+
257
+ <li class="public ">
258
+ <span class="summary_signature">
259
+
260
+ <a href="#version-class_method" title="version (class method)">+ (Object) <strong>version</strong> </a>
261
+
262
+
263
+
264
+ </span>
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+ <span class="summary_desc"><div class='inline'></div></span>
275
+
276
+ </li>
277
+
278
+
279
+ </ul>
280
+
234
281
  <h2>
235
282
  Instance Method Summary
236
283
  <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
@@ -256,7 +303,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
256
303
 
257
304
 
258
305
  <span class="summary_desc"><div class='inline'>
259
- <p>Get operator.</p>
306
+ <p>Get operator (See: <span class='object_link'><a href="#get-instance_method" title="UniCache#get (method)">#get</a></span>).</p>
260
307
  </div></span>
261
308
 
262
309
  </li>
@@ -280,7 +327,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
280
327
 
281
328
 
282
329
  <span class="summary_desc"><div class='inline'>
283
- <p>Put operator.</p>
330
+ <p>Put operator (See: <span class='object_link'><a href="#put-instance_method" title="UniCache#put (method)">#put</a></span>).</p>
284
331
  </div></span>
285
332
 
286
333
  </li>
@@ -307,6 +354,30 @@ Miss: 2:&lt;NA&gt;</code></pre>
307
354
  <p>Clear all Cache entries.</p>
308
355
  </div></span>
309
356
 
357
+ </li>
358
+
359
+
360
+ <li class="public ">
361
+ <span class="summary_signature">
362
+
363
+ <a href="#close-instance_method" title="#close (instance method)">- (Object) <strong>close</strong> </a>
364
+
365
+
366
+
367
+ </span>
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+ <span class="summary_desc"><div class='inline'>
378
+ <p>Close <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> access.</p>
379
+ </div></span>
380
+
310
381
  </li>
311
382
 
312
383
 
@@ -447,6 +518,30 @@ Miss: 2:&lt;NA&gt;</code></pre>
447
518
  <p>Cache initialization.</p>
448
519
  </div></span>
449
520
 
521
+ </li>
522
+
523
+
524
+ <li class="public ">
525
+ <span class="summary_signature">
526
+
527
+ <a href="#open-instance_method" title="#open (instance method)">- (Object) <strong>open</strong> </a>
528
+
529
+
530
+
531
+ </span>
532
+
533
+
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+ <span class="summary_desc"><div class='inline'>
542
+ <p>Open <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> for access.</p>
543
+ </div></span>
544
+
450
545
  </li>
451
546
 
452
547
 
@@ -573,7 +668,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
573
668
  <li class="public ">
574
669
  <span class="summary_signature">
575
670
 
576
- <a href="#resize-instance_method" title="#resize (instance method)">- (Object) <strong>resize</strong>(size) </a>
671
+ <a href="#resize-instance_method" title="#resize (instance method)">- (Integer) <strong>resize</strong>(size) </a>
577
672
 
578
673
 
579
674
 
@@ -681,7 +776,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
681
776
 
682
777
  &mdash;
683
778
  <div class='inline'>
684
- <p>Cache size.</p>
779
+ <p>Cache size (&gt; 0), nil for infinite size.</p>
685
780
  </div>
686
781
 
687
782
  </li>
@@ -713,8 +808,6 @@ Miss: 2:&lt;NA&gt;</code></pre>
713
808
  <pre class="lines">
714
809
 
715
810
 
716
- 72
717
- 73
718
811
  74
719
812
  75
720
813
  76
@@ -726,10 +819,12 @@ Miss: 2:&lt;NA&gt;</code></pre>
726
819
  82
727
820
  83
728
821
  84
729
- 85</pre>
822
+ 85
823
+ 86
824
+ 87</pre>
730
825
  </td>
731
826
  <td>
732
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 72</span>
827
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 74</span>
733
828
 
734
829
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span> <span class='id identifier rubyid_size'>size</span><span class='comma'>,</span> <span class='id identifier rubyid_evict'>evict</span> <span class='op'>=</span> <span class='const'>LruEviction</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='rparen'>)</span>
735
830
  <span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
@@ -740,7 +835,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
740
835
 
741
836
  <span class='id identifier rubyid_setEviction'>setEviction</span><span class='lparen'>(</span> <span class='id identifier rubyid_evict'>evict</span> <span class='rparen'>)</span>
742
837
 
743
- <span class='ivar'>@cb</span> <span class='op'>=</span> <span class='const'>NotifyHub</span><span class='period'>.</span><span class='id identifier rubyid_declare'>declare</span><span class='lparen'>(</span> <span class='symbol'>:getdata</span><span class='comma'>,</span>
838
+ <span class='ivar'>@cb</span> <span class='op'>=</span> <span class='const'>NotifyHub</span><span class='period'>.</span><span class='id identifier rubyid_declare'>declare</span><span class='lparen'>(</span> <span class='symbol'>:open</span><span class='comma'>,</span> <span class='symbol'>:close</span><span class='comma'>,</span> <span class='symbol'>:getdata</span><span class='comma'>,</span>
744
839
  <span class='symbol'>:add</span><span class='comma'>,</span> <span class='symbol'>:replace</span><span class='comma'>,</span> <span class='symbol'>:put</span><span class='comma'>,</span> <span class='symbol'>:overwrite</span><span class='comma'>,</span>
745
840
  <span class='symbol'>:remove</span><span class='comma'>,</span> <span class='symbol'>:valueremove</span><span class='comma'>,</span> <span class='symbol'>:hit</span><span class='comma'>,</span> <span class='symbol'>:miss</span><span class='comma'>,</span>
746
841
  <span class='symbol'>:peek</span> <span class='rparen'>)</span>
@@ -783,12 +878,12 @@ Miss: 2:&lt;NA&gt;</code></pre>
783
878
  <pre class="lines">
784
879
 
785
880
 
786
- 65
787
- 66
788
- 67</pre>
881
+ 67
882
+ 68
883
+ 69</pre>
789
884
  </td>
790
885
  <td>
791
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 65</span>
886
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 67</span>
792
887
 
793
888
  <span class='kw'>def</span> <span class='id identifier rubyid_lock'>lock</span>
794
889
  <span class='ivar'>@lock</span>
@@ -826,12 +921,12 @@ Miss: 2:&lt;NA&gt;</code></pre>
826
921
  <pre class="lines">
827
922
 
828
923
 
829
- 62
830
- 63
831
- 64</pre>
924
+ 64
925
+ 65
926
+ 66</pre>
832
927
  </td>
833
928
  <td>
834
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 62</span>
929
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 64</span>
835
930
 
836
931
  <span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
837
932
  <span class='ivar'>@size</span>
@@ -844,6 +939,42 @@ Miss: 2:&lt;NA&gt;</code></pre>
844
939
  </div>
845
940
 
846
941
 
942
+ <div id="class_method_details" class="method_details_list">
943
+ <h2>Class Method Details</h2>
944
+
945
+
946
+ <div class="method_details first">
947
+ <h3 class="signature first" id="version-class_method">
948
+
949
+ + (<tt>Object</tt>) <strong>version</strong>
950
+
951
+
952
+
953
+
954
+
955
+ </h3><table class="source_code">
956
+ <tr>
957
+ <td>
958
+ <pre class="lines">
959
+
960
+
961
+ 3
962
+ 4
963
+ 5</pre>
964
+ </td>
965
+ <td>
966
+ <pre class="code"><span class="info file"># File 'lib/version.rb', line 3</span>
967
+
968
+ <span class='kw'>def</span> <span class='const'>UniCache</span><span class='period'>.</span><span class='id identifier rubyid_version'>version</span>
969
+ <span class='const'>VERSION</span>
970
+ <span class='kw'>end</span></pre>
971
+ </td>
972
+ </tr>
973
+ </table>
974
+ </div>
975
+
976
+ </div>
977
+
847
978
  <div id="instance_method_details" class="method_details_list">
848
979
  <h2>Instance Method Details</h2>
849
980
 
@@ -860,7 +991,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
860
991
  </h3><div class="docstring">
861
992
  <div class="discussion">
862
993
 
863
- <p>Get operator.</p>
994
+ <p>Get operator (See: <span class='object_link'><a href="#get-instance_method" title="UniCache#get (method)">#get</a></span>)</p>
864
995
 
865
996
 
866
997
  </div>
@@ -874,12 +1005,12 @@ Miss: 2:&lt;NA&gt;</code></pre>
874
1005
  <pre class="lines">
875
1006
 
876
1007
 
877
- 158
878
- 159
879
- 160</pre>
1008
+ 177
1009
+ 178
1010
+ 179</pre>
880
1011
  </td>
881
1012
  <td>
882
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 158</span>
1013
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 177</span>
883
1014
 
884
1015
  <span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
885
1016
  <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
@@ -901,7 +1032,7 @@ Miss: 2:&lt;NA&gt;</code></pre>
901
1032
  </h3><div class="docstring">
902
1033
  <div class="discussion">
903
1034
 
904
- <p>Put operator.</p>
1035
+ <p>Put operator (See: <span class='object_link'><a href="#put-instance_method" title="UniCache#put (method)">#put</a></span>)</p>
905
1036
 
906
1037
 
907
1038
  </div>
@@ -915,12 +1046,12 @@ Miss: 2:&lt;NA&gt;</code></pre>
915
1046
  <pre class="lines">
916
1047
 
917
1048
 
918
- 133
919
- 134
920
- 135</pre>
1049
+ 152
1050
+ 153
1051
+ 154</pre>
921
1052
  </td>
922
1053
  <td>
923
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 133</span>
1054
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 152</span>
924
1055
 
925
1056
  <span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='rparen'>)</span>
926
1057
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='rparen'>)</span>
@@ -956,17 +1087,17 @@ Miss: 2:&lt;NA&gt;</code></pre>
956
1087
  <pre class="lines">
957
1088
 
958
1089
 
959
- 283
960
- 284
961
- 285
962
- 286
963
- 287
964
- 288
965
- 289
966
- 290</pre>
1090
+ 316
1091
+ 317
1092
+ 318
1093
+ 319
1094
+ 320
1095
+ 321
1096
+ 322
1097
+ 323</pre>
967
1098
  </td>
968
1099
  <td>
969
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 283</span>
1100
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 316</span>
970
1101
 
971
1102
  <span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
972
1103
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
@@ -979,6 +1110,48 @@ Miss: 2:&lt;NA&gt;</code></pre>
979
1110
  </td>
980
1111
  </tr>
981
1112
  </table>
1113
+ </div>
1114
+
1115
+ <div class="method_details ">
1116
+ <h3 class="signature " id="close-instance_method">
1117
+
1118
+ - (<tt>Object</tt>) <strong>close</strong>
1119
+
1120
+
1121
+
1122
+
1123
+
1124
+ </h3><div class="docstring">
1125
+ <div class="discussion">
1126
+
1127
+ <p>Close <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> access. The ":close" callback is executed. Typically the
1128
+ user would perform <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> content store with the callback.</p>
1129
+
1130
+
1131
+ </div>
1132
+ </div>
1133
+ <div class="tags">
1134
+
1135
+
1136
+ </div><table class="source_code">
1137
+ <tr>
1138
+ <td>
1139
+ <pre class="lines">
1140
+
1141
+
1142
+ 126
1143
+ 127
1144
+ 128</pre>
1145
+ </td>
1146
+ <td>
1147
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 126</span>
1148
+
1149
+ <span class='kw'>def</span> <span class='id identifier rubyid_close'>close</span>
1150
+ <span class='id identifier rubyid_runCallbacks'>runCallbacks</span><span class='lparen'>(</span> <span class='symbol'>:close</span><span class='comma'>,</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
1151
+ <span class='kw'>end</span></pre>
1152
+ </td>
1153
+ </tr>
1154
+ </table>
982
1155
  </div>
983
1156
 
984
1157
  <div class="method_details ">
@@ -993,8 +1166,8 @@ Miss: 2:&lt;NA&gt;</code></pre>
993
1166
  </h3><div class="docstring">
994
1167
  <div class="discussion">
995
1168
 
996
- <p>Get Cache entry existance by key (no effect to eviction). Uses "peek", i.e.
997
- peek CB is run.</p>
1169
+ <p>Get Cache entry existance by key (no effect to eviction). Uses
1170
+ <span class='object_link'><a href="#peek-instance_method" title="UniCache#peek (method)">#peek</a></span>, i.e. peek CB is run.</p>
998
1171
 
999
1172
 
1000
1173
  </div>
@@ -1041,16 +1214,16 @@ peek CB is run.</p>
1041
1214
  <pre class="lines">
1042
1215
 
1043
1216
 
1044
- 176
1045
- 177
1046
- 178
1047
- 179
1048
- 180
1049
- 181
1050
- 182</pre>
1217
+ 195
1218
+ 196
1219
+ 197
1220
+ 198
1221
+ 199
1222
+ 200
1223
+ 201</pre>
1051
1224
  </td>
1052
1225
  <td>
1053
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 176</span>
1226
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 195</span>
1054
1227
 
1055
1228
  <span class='kw'>def</span> <span class='id identifier rubyid_exist?'>exist?</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
1056
1229
  <span class='kw'>if</span> <span class='id identifier rubyid_peek'>peek</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
@@ -1078,11 +1251,11 @@ peek CB is run.</p>
1078
1251
 
1079
1252
  <p>Get Cache entry by key or return nil if not in Cache.</p>
1080
1253
 
1081
- <p>If block is provided, it is run under UniCache lock and will protect the
1254
+ <p>If block is provided, it is run under <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> lock and will protect the
1082
1255
  used data from being removed (concurrently).</p>
1083
1256
 
1084
1257
  <p>If ":getdata" callback is defined, it is used to get data. Data is always
1085
- used, also when nil. UniCache lock is released before callback is called.</p>
1258
+ used, also when nil. <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> lock is released before callback is called.</p>
1086
1259
 
1087
1260
 
1088
1261
  </div>
@@ -1121,7 +1294,7 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1121
1294
 
1122
1295
 
1123
1296
  <div class='inline'>
1124
- <p>Procedure to fetch the data.</p>
1297
+ <p>Procedure to run with the data.</p>
1125
1298
  </div>
1126
1299
 
1127
1300
  </li>
@@ -1134,21 +1307,21 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1134
1307
  <pre class="lines">
1135
1308
 
1136
1309
 
1137
- 149
1138
- 150
1139
- 151
1140
- 152
1141
- 153
1142
- 154</pre>
1310
+ 168
1311
+ 169
1312
+ 170
1313
+ 171
1314
+ 172
1315
+ 173</pre>
1143
1316
  </td>
1144
1317
  <td>
1145
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 149</span>
1318
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 168</span>
1146
1319
 
1147
1320
  <span class='kw'>def</span> <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span> <span class='rparen'>)</span>
1148
1321
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
1149
1322
  <span class='id identifier rubyid_ret'>ret</span> <span class='op'>=</span> <span class='id identifier rubyid__get'>_get</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span> <span class='rparen'>)</span>
1150
1323
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_unlock'>unlock</span>
1151
- <span class='id identifier rubyid_ret'>ret</span>
1324
+ <span class='id identifier rubyid_ret'>ret</span>
1152
1325
  <span class='kw'>end</span></pre>
1153
1326
  </td>
1154
1327
  </tr>
@@ -1170,10 +1343,10 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1170
1343
  <pre class="lines">
1171
1344
 
1172
1345
 
1173
- 97</pre>
1346
+ 99</pre>
1174
1347
  </td>
1175
1348
  <td>
1176
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 97</span>
1349
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 99</span>
1177
1350
 
1178
1351
  <span class='kw'>alias</span> <span class='symbol'>:hash_get_op</span> <span class='symbol'>:[]</span></pre>
1179
1352
  </td>
@@ -1196,10 +1369,10 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1196
1369
  <pre class="lines">
1197
1370
 
1198
1371
 
1199
- 96</pre>
1372
+ 98</pre>
1200
1373
  </td>
1201
1374
  <td>
1202
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 96</span>
1375
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 98</span>
1203
1376
 
1204
1377
  <span class='kw'>alias</span> <span class='symbol'>:hash_set_op</span> <span class='symbol'>:[]=</span></pre>
1205
1378
  </td>
@@ -1222,15 +1395,57 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1222
1395
  <pre class="lines">
1223
1396
 
1224
1397
 
1225
- 99</pre>
1398
+ 101</pre>
1226
1399
  </td>
1227
1400
  <td>
1228
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 99</span>
1401
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 101</span>
1229
1402
 
1230
1403
  <span class='kw'>alias</span> <span class='symbol'>:hash_store</span> <span class='symbol'>:store</span></pre>
1231
1404
  </td>
1232
1405
  </tr>
1233
1406
  </table>
1407
+ </div>
1408
+
1409
+ <div class="method_details ">
1410
+ <h3 class="signature " id="open-instance_method">
1411
+
1412
+ - (<tt>Object</tt>) <strong>open</strong>
1413
+
1414
+
1415
+
1416
+
1417
+
1418
+ </h3><div class="docstring">
1419
+ <div class="discussion">
1420
+
1421
+ <p>Open <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> for access. The ":open" callback is executed. Typically the
1422
+ user would perform <span class='object_link'><a href="" title="UniCache (class)">UniCache</a></span> content initialization with the callback.</p>
1423
+
1424
+
1425
+ </div>
1426
+ </div>
1427
+ <div class="tags">
1428
+
1429
+
1430
+ </div><table class="source_code">
1431
+ <tr>
1432
+ <td>
1433
+ <pre class="lines">
1434
+
1435
+
1436
+ 118
1437
+ 119
1438
+ 120</pre>
1439
+ </td>
1440
+ <td>
1441
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 118</span>
1442
+
1443
+ <span class='kw'>def</span> <span class='id identifier rubyid_open'>open</span>
1444
+ <span class='id identifier rubyid_runCallbacks'>runCallbacks</span><span class='lparen'>(</span> <span class='symbol'>:open</span><span class='comma'>,</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
1445
+ <span class='kw'>end</span></pre>
1446
+ </td>
1447
+ </tr>
1448
+ </table>
1234
1449
  </div>
1235
1450
 
1236
1451
  <div class="method_details ">
@@ -1279,13 +1494,13 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1279
1494
  <pre class="lines">
1280
1495
 
1281
1496
 
1282
- 166
1283
- 167
1284
- 168
1285
- 169</pre>
1497
+ 185
1498
+ 186
1499
+ 187
1500
+ 188</pre>
1286
1501
  </td>
1287
1502
  <td>
1288
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 166</span>
1503
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 185</span>
1289
1504
 
1290
1505
  <span class='kw'>def</span> <span class='id identifier rubyid_peek'>peek</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
1291
1506
  <span class='id identifier rubyid_runCallbacks'>runCallbacks</span><span class='lparen'>(</span> <span class='symbol'>:peek</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
@@ -1358,21 +1573,21 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1358
1573
  <pre class="lines">
1359
1574
 
1360
1575
 
1361
- 124
1362
- 125
1363
- 126
1364
- 127
1365
- 128
1366
- 129</pre>
1576
+ 143
1577
+ 144
1578
+ 145
1579
+ 146
1580
+ 147
1581
+ 148</pre>
1367
1582
  </td>
1368
1583
  <td>
1369
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 124</span>
1584
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 143</span>
1370
1585
 
1371
1586
  <span class='kw'>def</span> <span class='id identifier rubyid_put'>put</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='rparen'>)</span>
1372
1587
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
1373
1588
  <span class='id identifier rubyid_ret'>ret</span> <span class='op'>=</span> <span class='id identifier rubyid__put'>_put</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='rparen'>)</span>
1374
1589
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_unlock'>unlock</span>
1375
- <span class='id identifier rubyid_ret'>ret</span>
1590
+ <span class='id identifier rubyid_ret'>ret</span>
1376
1591
  <span class='kw'>end</span></pre>
1377
1592
  </td>
1378
1593
  </tr>
@@ -1391,52 +1606,62 @@ used, also when nil. UniCache lock is released before callback is called.</p>
1391
1606
  </h3><div class="docstring">
1392
1607
  <div class="discussion">
1393
1608
 
1394
- <p>Register a callback to be executed on Cache event.</p>
1609
+ <p>Register a callback to be executed on Cache event. Callbacks are passed
1610
+ with following arguments: CacheKey, CacheValue, CacheObject.</p>
1395
1611
 
1396
1612
  <p>Possible events:</p>
1397
- <dl class="rdoc-list"><dt>getdata</dt>
1613
+ <dl class="rdoc-list"><dt>:open</dt>
1614
+ <dd>
1615
+ <p>Called when <span class='object_link'><a href="#open-instance_method" title="UniCache#open (method)">#open</a></span> is executed. This is typically used to
1616
+ initialize the UniCache content.</p>
1617
+ </dd><dt>:close</dt>
1618
+ <dd>
1619
+ <p>Called when <span class='object_link'><a href="#close-instance_method" title="UniCache#close (method)">#close</a></span> is executed. This is typically used to store
1620
+ the UniCache content for next session.</p>
1621
+ </dd><dt>:getdata</dt>
1398
1622
  <dd>
1399
1623
  <p>Data not found in cache, callback is used to fetch it. Data is always added
1400
1624
  to cache unless an exception is raised. Also all retrys should be captured
1401
1625
  into ":getdata". &lt;key,value&gt; from request.</p>
1402
- </dd><dt>add</dt>
1626
+ </dd><dt>:add</dt>
1403
1627
  <dd>
1404
1628
  <p>Item is added to Cache without anything being replaced. &lt;key,value&gt;
1405
1629
  from request.</p>
1406
- </dd><dt>replace</dt>
1630
+ </dd><dt>:replace</dt>
1407
1631
  <dd>
1408
1632
  <p>Item is added to Cache and another item is removed. &lt;key,value&gt; is
1409
1633
  evicted entry.</p>
1410
- </dd><dt>put</dt>
1634
+ </dd><dt>:put</dt>
1411
1635
  <dd>
1412
1636
  <p>Item is added to Cache. Cache conditions has no effect i.e. always run for
1413
1637
  "put". &lt;key,value&gt; from request.</p>
1414
- </dd><dt>overwrite</dt>
1638
+ </dd><dt>:overwrite</dt>
1415
1639
  <dd>
1416
1640
  <p>Existing entry value is replaced by new item value. &lt;key,value&gt; from
1417
1641
  request.</p>
1418
- </dd><dt>remove</dt>
1642
+ </dd><dt>:remove</dt>
1419
1643
  <dd>
1420
1644
  <p>Entry is deleted from Cache.</p>
1421
- </dd><dt>valueremove</dt>
1645
+ </dd><dt>:valueremove</dt>
1422
1646
  <dd>
1423
1647
  <p>Entry value is removed (remove or overwrite). &lt;key,value&gt; from old
1424
1648
  entry.</p>
1425
- </dd><dt>hit</dt>
1649
+ </dd><dt>:hit</dt>
1426
1650
  <dd>
1427
1651
  <p>Entry is found in Cache. &lt;key,value&gt; from cache.</p>
1428
- </dd><dt>miss</dt>
1652
+ </dd><dt>:miss</dt>
1429
1653
  <dd>
1430
1654
  <p>Entry is not found in Cache. &lt;key&gt; from request.</p>
1431
- </dd><dt>peek</dt>
1655
+ </dd><dt>:peek</dt>
1432
1656
  <dd>
1433
1657
  <p>Cache peek. &lt;key,value&gt; from request.</p>
1434
1658
  </dd></dl>
1435
1659
 
1436
1660
  <p>Example:</p>
1437
1661
 
1438
- <pre class="code ruby"><code class="ruby">registerCallback( :add,
1439
- Proc.new do |k,v,o| puts &quot;Key: #{k} with value #{v} added&quot; end</code></pre>
1662
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_registerCallback'>registerCallback</span><span class='lparen'>(</span> <span class='symbol'>:add</span><span class='comma'>,</span>
1663
+ <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='comma'>,</span><span class='id identifier rubyid_o'>o</span><span class='op'>|</span> <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Key: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='rbrace'>}</span><span class='tstring_content'> with value </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_v'>v</span><span class='rbrace'>}</span><span class='tstring_content'> added</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>end</span>
1664
+ <span class='rparen'>)</span></code></pre>
1440
1665
 
1441
1666
 
1442
1667
  </div>
@@ -1486,16 +1711,16 @@ entry.</p>
1486
1711
  <pre class="lines">
1487
1712
 
1488
1713
 
1489
- 259
1490
- 260
1491
- 261
1492
- 262
1493
- 263
1494
- 264
1495
- 265</pre>
1714
+ 292
1715
+ 293
1716
+ 294
1717
+ 295
1718
+ 296
1719
+ 297
1720
+ 298</pre>
1496
1721
  </td>
1497
1722
  <td>
1498
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 259</span>
1723
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 292</span>
1499
1724
 
1500
1725
  <span class='kw'>def</span> <span class='id identifier rubyid_registerCallback'>registerCallback</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_proc'>proc</span> <span class='rparen'>)</span>
1501
1726
  <span class='kw'>begin</span>
@@ -1575,15 +1800,15 @@ entry.</p>
1575
1800
  <pre class="lines">
1576
1801
 
1577
1802
 
1578
- 189
1579
- 190
1580
- 191
1581
- 192
1582
- 193
1583
- 194</pre>
1803
+ 208
1804
+ 209
1805
+ 210
1806
+ 211
1807
+ 212
1808
+ 213</pre>
1584
1809
  </td>
1585
1810
  <td>
1586
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 189</span>
1811
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 208</span>
1587
1812
 
1588
1813
  <span class='kw'>def</span> <span class='id identifier rubyid_remove'>remove</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
1589
1814
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
@@ -1644,18 +1869,18 @@ entry.</p>
1644
1869
  <pre class="lines">
1645
1870
 
1646
1871
 
1647
- 271
1648
- 272
1649
- 273
1650
- 274
1651
- 275
1652
- 276
1653
- 277
1654
- 278
1655
- 279</pre>
1872
+ 304
1873
+ 305
1874
+ 306
1875
+ 307
1876
+ 308
1877
+ 309
1878
+ 310
1879
+ 311
1880
+ 312</pre>
1656
1881
  </td>
1657
1882
  <td>
1658
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 271</span>
1883
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 304</span>
1659
1884
 
1660
1885
  <span class='kw'>def</span> <span class='id identifier rubyid_removeCallback'>removeCallback</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
1661
1886
  <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span>
@@ -1674,7 +1899,7 @@ entry.</p>
1674
1899
  <div class="method_details ">
1675
1900
  <h3 class="signature " id="resize-instance_method">
1676
1901
 
1677
- - (<tt>Object</tt>) <strong>resize</strong>(size)
1902
+ - (<tt>Integer</tt>) <strong>resize</strong>(size)
1678
1903
 
1679
1904
 
1680
1905
 
@@ -1703,13 +1928,31 @@ entry.</p>
1703
1928
 
1704
1929
  &mdash;
1705
1930
  <div class='inline'>
1706
- <p>New Cache size.</p>
1931
+ <p>New Cache size, “&gt; 0” or “nil”.</p>
1707
1932
  </div>
1708
1933
 
1709
1934
  </li>
1710
1935
 
1711
1936
  </ul>
1712
1937
 
1938
+ <p class="tag_title">Returns:</p>
1939
+ <ul class="return">
1940
+
1941
+ <li>
1942
+
1943
+
1944
+ <span class='type'>(<tt>Integer</tt>)</span>
1945
+
1946
+
1947
+
1948
+ &mdash;
1949
+ <div class='inline'>
1950
+ <p>New Cache size.</p>
1951
+ </div>
1952
+
1953
+ </li>
1954
+
1955
+ </ul>
1713
1956
  <p class="tag_title">Raises:</p>
1714
1957
  <ul class="raise">
1715
1958
 
@@ -1730,31 +1973,35 @@ entry.</p>
1730
1973
  <pre class="lines">
1731
1974
 
1732
1975
 
1733
- 200
1734
- 201
1735
- 202
1736
- 203
1737
- 204
1738
- 205
1739
- 206
1740
- 207
1741
- 208
1742
- 209
1743
- 210
1744
- 211
1745
- 212
1746
- 213
1747
- 214
1748
- 215
1749
- 216
1750
- 217
1751
- 218</pre>
1976
+ 220
1977
+ 221
1978
+ 222
1979
+ 223
1980
+ 224
1981
+ 225
1982
+ 226
1983
+ 227
1984
+ 228
1985
+ 229
1986
+ 230
1987
+ 231
1988
+ 232
1989
+ 233
1990
+ 234
1991
+ 235
1992
+ 236
1993
+ 237
1994
+ 238
1995
+ 239
1996
+ 240</pre>
1752
1997
  </td>
1753
1998
  <td>
1754
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 200</span>
1999
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 220</span>
1755
2000
 
1756
2001
  <span class='kw'>def</span> <span class='id identifier rubyid_resize'>resize</span><span class='lparen'>(</span> <span class='id identifier rubyid_size'>size</span> <span class='rparen'>)</span>
1757
-
2002
+
2003
+ <span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='kw'>nil</span>
2004
+
1758
2005
  <span class='id identifier rubyid_raise'>raise</span> <span class='const'>SizeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>UniCache: Size must be bigger than 0</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_size'>size</span> <span class='op'>&gt;</span> <span class='int'>0</span>
1759
2006
 
1760
2007
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
@@ -1823,12 +2070,12 @@ entry.</p>
1823
2070
  <pre class="lines">
1824
2071
 
1825
2072
 
1826
- 91
1827
- 92
1828
- 93</pre>
2073
+ 93
2074
+ 94
2075
+ 95</pre>
1829
2076
  </td>
1830
2077
  <td>
1831
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 91</span>
2078
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 93</span>
1832
2079
 
1833
2080
  <span class='kw'>def</span> <span class='id identifier rubyid_setEviction'>setEviction</span><span class='lparen'>(</span> <span class='id identifier rubyid_evict'>evict</span> <span class='rparen'>)</span>
1834
2081
  <span class='ivar'>@evict</span> <span class='op'>=</span> <span class='id identifier rubyid_evict'>evict</span>
@@ -1864,10 +2111,10 @@ entry.</p>
1864
2111
  <pre class="lines">
1865
2112
 
1866
2113
 
1867
- 113</pre>
2114
+ 132</pre>
1868
2115
  </td>
1869
2116
  <td>
1870
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 113</span>
2117
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 132</span>
1871
2118
 
1872
2119
  <span class='kw'>def</span> <span class='id identifier rubyid_store'>store</span><span class='lparen'>(</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
1873
2120
  </td>
@@ -1880,7 +2127,7 @@ entry.</p>
1880
2127
  </div>
1881
2128
 
1882
2129
  <div id="footer">
1883
- Generated on Mon Feb 10 23:59:39 2014 by
2130
+ Generated on Thu Jul 17 14:54:03 2014 by
1884
2131
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1885
2132
  0.8.6.1 (ruby-1.9.3).
1886
2133
  </div>