unicache 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Thu Jul 17 14:54:03 2014 by
136
+ Generated on Sun Nov 23 14:33:03 2014 by
137
137
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.8.6.1 (ruby-1.9.3).
139
139
  </div>
@@ -129,7 +129,7 @@
129
129
  </div>
130
130
 
131
131
  <div id="footer">
132
- Generated on Thu Jul 17 14:54:03 2014 by
132
+ Generated on Sun Nov 23 14:33:03 2014 by
133
133
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
134
134
  0.8.6.1 (ruby-1.9.3).
135
135
  </div>
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Thu Jul 17 14:54:03 2014 by
136
+ Generated on Sun Nov 23 14:33:03 2014 by
137
137
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.8.6.1 (ruby-1.9.3).
139
139
  </div>
@@ -295,13 +295,13 @@ of operations.</p>
295
295
  <pre class="lines">
296
296
 
297
297
 
298
- 340
299
- 341
300
- 342
301
- 343</pre>
298
+ 359
299
+ 360
300
+ 361
301
+ 362</pre>
302
302
  </td>
303
303
  <td>
304
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 340</span>
304
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 359</span>
305
305
 
306
306
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
307
307
  <span class='ivar'>@lock</span> <span class='op'>=</span> <span class='const'>Mutex</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
@@ -345,14 +345,14 @@ of operations.</p>
345
345
  <pre class="lines">
346
346
 
347
347
 
348
- 347
349
- 348
350
- 349
351
- 350
352
- 351</pre>
348
+ 366
349
+ 367
350
+ 368
351
+ 369
352
+ 370</pre>
353
353
  </td>
354
354
  <td>
355
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 347</span>
355
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 366</span>
356
356
 
357
357
  <span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
358
358
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
@@ -390,12 +390,12 @@ of operations.</p>
390
390
  <pre class="lines">
391
391
 
392
392
 
393
- 394
394
- 395
395
- 396</pre>
393
+ 413
394
+ 414
395
+ 415</pre>
396
396
  </td>
397
397
  <td>
398
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 394</span>
398
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 413</span>
399
399
 
400
400
  <span class='kw'>def</span> <span class='id identifier rubyid_nextEvict'>nextEvict</span>
401
401
  <span class='ivar'>@list</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
@@ -453,25 +453,25 @@ of operations.</p>
453
453
  <pre class="lines">
454
454
 
455
455
 
456
- 375
457
- 376
458
- 377
459
- 378
460
- 379
461
- 380
462
- 381
463
- 382
464
- 383
465
- 384
466
- 385
467
- 386
468
- 387
469
- 388
470
- 389
471
- 390</pre>
456
+ 394
457
+ 395
458
+ 396
459
+ 397
460
+ 398
461
+ 399
462
+ 400
463
+ 401
464
+ 402
465
+ 403
466
+ 404
467
+ 405
468
+ 406
469
+ 407
470
+ 408
471
+ 409</pre>
472
472
  </td>
473
473
  <td>
474
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 375</span>
474
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 394</span>
475
475
 
476
476
  <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>
477
477
  <span class='ivar'>@lock</span><span class='period'>.</span><span class='id identifier rubyid_lock'>lock</span>
@@ -541,21 +541,21 @@ of the list.</p>
541
541
  <pre class="lines">
542
542
 
543
543
 
544
- 358
545
- 359
546
- 360
547
- 361
548
- 362
549
- 363
550
- 364
551
- 365
552
- 366
553
- 367
554
- 368
555
- 369</pre>
544
+ 377
545
+ 378
546
+ 379
547
+ 380
548
+ 381
549
+ 382
550
+ 383
551
+ 384
552
+ 385
553
+ 386
554
+ 387
555
+ 388</pre>
556
556
  </td>
557
557
  <td>
558
- <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 358</span>
558
+ <pre class="code"><span class="info file"># File 'lib/unicache.rb', line 377</span>
559
559
 
560
560
  <span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span> <span class='id identifier rubyid_key'>key</span> <span class='rparen'>)</span>
561
561
 
@@ -579,7 +579,7 @@ of the list.</p>
579
579
  </div>
580
580
 
581
581
  <div id="footer">
582
- Generated on Thu Jul 17 14:54:03 2014 by
582
+ Generated on Sun Nov 23 14:33:03 2014 by
583
583
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
584
584
  0.8.6.1 (ruby-1.9.3).
585
585
  </div>
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Thu Jul 17 14:54:03 2014 by
136
+ Generated on Sun Nov 23 14:33:03 2014 by
137
137
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.8.6.1 (ruby-1.9.3).
139
139
  </div>
@@ -133,7 +133,7 @@
133
133
  </div>
134
134
 
135
135
  <div id="footer">
136
- Generated on Thu Jul 17 14:54:03 2014 by
136
+ Generated on Sun Nov 23 14:33:03 2014 by
137
137
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
138
138
  0.8.6.1 (ruby-1.9.3).
139
139
  </div>
data/doc/_index.html CHANGED
@@ -194,7 +194,7 @@
194
194
  </div>
195
195
 
196
196
  <div id="footer">
197
- Generated on Thu Jul 17 14:54:02 2014 by
197
+ Generated on Sun Nov 23 14:33:03 2014 by
198
198
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
199
199
  0.8.6.1 (ruby-1.9.3).
200
200
  </div>
@@ -63,7 +63,10 @@
63
63
 
64
64
  <div id="content"><div id='filecontents'>
65
65
  <h1>Version history</h1>
66
- <dl class="rdoc-list"><dt>0.0.3</dt>
66
+ <dl class="rdoc-list"><dt>0.0.4</dt>
67
+ <dd>
68
+ <p>Documentation improvements. Added version method.</p>
69
+ </dd><dt>0.0.3</dt>
67
70
  <dd>
68
71
  <p>"open" and "close" method for cache content init and dump. Size can be
69
72
  "nil" (unlimited size).</p>
@@ -77,7 +80,7 @@
77
80
  </div></div>
78
81
 
79
82
  <div id="footer">
80
- Generated on Thu Jul 17 14:54:02 2014 by
83
+ Generated on Sun Nov 23 14:33:03 2014 by
81
84
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
82
85
  0.8.6.1 (ruby-1.9.3).
83
86
  </div>
data/doc/file.README.html CHANGED
@@ -66,20 +66,21 @@
66
66
 
67
67
  <h2>Description</h2>
68
68
 
69
- <p>UniCache is a universal purpose cache with Least Recently Used replacement
70
- policy by default. Cache can be configured to use another policy.</p>
69
+ <p><span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> is a universal purpose cache with Least Recently Used
70
+ replacement policy by default. Cache can be configured to use another
71
+ policy.</p>
71
72
 
72
- <p>UniCache is intended to be Thread safe.</p>
73
+ <p><span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> is intended to be Thread safe.</p>
73
74
 
74
- <p>User can register callbacks that are run at various UniCache events.</p>
75
+ <p>User can register callbacks that are run at various <span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> events.</p>
75
76
 
76
77
  <h2>Documentation</h2>
77
78
 
78
- <p>Main documentation is generated from UniCache source.</p>
79
+ <p>Main documentation is generated from <span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> source.</p>
79
80
  </div></div>
80
81
 
81
82
  <div id="footer">
82
- Generated on Thu Jul 17 14:54:02 2014 by
83
+ Generated on Sun Nov 23 14:33:03 2014 by
83
84
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
84
85
  0.8.6.1 (ruby-1.9.3).
85
86
  </div>
data/doc/index.html CHANGED
@@ -66,20 +66,21 @@
66
66
 
67
67
  <h2>Description</h2>
68
68
 
69
- <p>UniCache is a universal purpose cache with Least Recently Used replacement
70
- policy by default. Cache can be configured to use another policy.</p>
69
+ <p><span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> is a universal purpose cache with Least Recently Used
70
+ replacement policy by default. Cache can be configured to use another
71
+ policy.</p>
71
72
 
72
- <p>UniCache is intended to be Thread safe.</p>
73
+ <p><span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> is intended to be Thread safe.</p>
73
74
 
74
- <p>User can register callbacks that are run at various UniCache events.</p>
75
+ <p>User can register callbacks that are run at various <span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> events.</p>
75
76
 
76
77
  <h2>Documentation</h2>
77
78
 
78
- <p>Main documentation is generated from UniCache source.</p>
79
+ <p>Main documentation is generated from <span class='object_link'><a href="UniCache.html" title="UniCache (class)">UniCache</a></span> source.</p>
79
80
  </div></div>
80
81
 
81
82
  <div id="footer">
82
- Generated on Thu Jul 17 14:54:02 2014 by
83
+ Generated on Sun Nov 23 14:33:03 2014 by
83
84
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
84
85
  0.8.6.1 (ruby-1.9.3).
85
86
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Thu Jul 17 14:54:02 2014 by
106
+ Generated on Sun Nov 23 14:33:03 2014 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.6.1 (ruby-1.9.3).
109
109
  </div>
data/lib/unicache.rb CHANGED
@@ -2,13 +2,23 @@
2
2
  # replacement policy by default. Cache can be configured with another
3
3
  # policy.
4
4
  #
5
- # {UniCache} is intended to be Thread safe.
5
+ # {UniCache} is created with defined size (or without size
6
+ # limitations). {UniCache} inherits Hash and thus almost all Hash
7
+ # methods are usable. The cache content is set and referenced using
8
+ # Hash methods.
6
9
  #
7
- # User can register callbacks that are run at various {UniCache} events.
8
- # ":getdata" callback is used to retreive cache data if not in
9
- # cache. Others do not effect the UniCache state.
10
+ # User can register callbacks that are run at various {UniCache}
11
+ # events (see: {UniCache#registerCallback}). ":getdata" callback is
12
+ # used to retreive cache data if not in cache. Other callbacks don't
13
+ # effect the UniCache state (unless explicitly changed).
14
+ #
15
+ # Cache can be setup with content using {UniCache#open} and content
16
+ # can be stored after use with {UniCache#close}. The "open"/"close"
17
+ # actions are defined in the corresponding callbacks.
18
+ #
19
+ # {UniCache} is intended to be Thread safe. It uses Mutex to implement
20
+ # access control.
10
21
  #
11
- # UniCache is inherits Hash, i.e. almost all Hash methods are usable.
12
22
  #
13
23
  # Usage example:
14
24
  # require 'unicache'
@@ -74,12 +84,16 @@ class UniCache < Hash
74
84
  def initialize( size, evict = LruEviction.new )
75
85
  super()
76
86
 
87
+ # Access control
77
88
  @lock = Mutex.new
78
89
 
90
+ # Set cache size.
79
91
  resize( size )
80
92
 
93
+ # Set eviction policy.
81
94
  setEviction( evict )
82
95
 
96
+ # Declare all callbacks.
83
97
  @cb = NotifyHub.declare( :open, :close, :getdata,
84
98
  :add, :replace, :put, :overwrite,
85
99
  :remove, :valueremove, :hit, :miss,
@@ -87,7 +101,8 @@ class UniCache < Hash
87
101
  end
88
102
 
89
103
 
90
- # Set the eviction policy.
104
+ # Set the eviction policy. Evictor should have the same interface
105
+ # as {UniCache.LruEviction}.
91
106
  #
92
107
  # @param evict [Object] Cache eviction policy.
93
108
  def setEviction( evict )
@@ -165,6 +180,7 @@ class UniCache < Hash
165
180
  #
166
181
  # @param key [Object] Key (or tag) of the Cache entry.
167
182
  # @yield Procedure to run with the data.
183
+ # @return [Object] Cache data.
168
184
  def get( key, &blk )
169
185
  @lock.lock
170
186
  ret = _get( key, &blk )
@@ -182,6 +198,7 @@ class UniCache < Hash
182
198
  # Get Cache entry by key (no effect to eviction).
183
199
  #
184
200
  # @param key [Object] Entry key or tag.
201
+ # @return [Object] Cache data.
185
202
  def peek( key )
186
203
  runCallbacks( :peek, key )
187
204
  hash_fetch( key, nil )
@@ -192,6 +209,7 @@ class UniCache < Hash
192
209
  # {UniCache#peek}, i.e. peek CB is run.
193
210
  #
194
211
  # @param key [Object] Entry key or tag.
212
+ # @return [Boolean] True if value found.
195
213
  def exist?( key )
196
214
  if peek( key )
197
215
  true
@@ -278,7 +296,8 @@ class UniCache < Hash
278
296
  #
279
297
  # [:hit] Entry is found in Cache. <key,value> from cache.
280
298
  #
281
- # [:miss] Entry is not found in Cache. <key> from request.
299
+ # [:miss] Entry is not found in Cache. <key> from
300
+ # request. Callback is called before ":getdata".
282
301
  #
283
302
  # [:peek] Cache peek. <key,value> from request.
284
303
  #
@@ -524,4 +543,4 @@ class UniCache < Hash
524
543
 
525
544
  end
526
545
 
527
- require 'version'
546
+ require_relative 'version'
data/lib/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class UniCache
2
- VERSION="0.0.3"
2
+ VERSION = "0.0.4"
3
3
  def UniCache.version
4
- VERSION
4
+ UniCache::VERSION
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,97 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tero Isannainen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-11-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: notifyhub
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.0.2
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.0.2
30
- description: ! 'UniCache is a universal purpose cache with Least Recently Used
31
-
32
- replacement policy by default. Cache can be configured to use another policy. UniCache
33
- is intended to be Thread safe. User can register callbacks that are run at various
34
- UniCache events.'
27
+ description: |-
28
+ UniCache is a universal purpose cache with Least Recently Used
29
+ replacement policy by default. Cache can be configured to use another policy. UniCache is intended to be Thread safe. User can register callbacks that are run at various UniCache events.
35
30
  email: tero.isannainen@gmail.com
36
31
  executables: []
37
32
  extensions: []
38
33
  extra_rdoc_files:
39
34
  - README.rdoc
40
35
  files:
41
- - README.rdoc
42
36
  - CHANGELOG.rdoc
43
37
  - LICENSE
44
- - Rakefile
45
- - lib/version.rb
46
- - lib/unicache.rb
47
- - test/test_all.rb
48
- - doc/top-level-namespace.html
49
- - doc/js/full_list.js
50
- - doc/js/app.js
51
- - doc/js/jquery.js
52
- - doc/index.html
53
- - doc/css/common.css
54
- - doc/css/full_list.css
55
- - doc/css/style.css
38
+ - README.rdoc
56
39
  - doc/UniCache.html
57
- - doc/file.README.html
58
- - doc/method_list.html
59
- - doc/file_list.html
60
- - doc/UniCache/UniCacheCommon.html
61
40
  - doc/UniCache/CallbackError.html
41
+ - doc/UniCache/Error.html
62
42
  - doc/UniCache/FetchError.html
63
43
  - doc/UniCache/LruEviction.html
64
- - doc/UniCache/Error.html
65
- - doc/UniCache/SizeError.html
66
44
  - doc/UniCache/RemoveError.html
67
- - doc/class_list.html
45
+ - doc/UniCache/SizeError.html
68
46
  - doc/_index.html
47
+ - doc/class_list.html
48
+ - doc/css/common.css
49
+ - doc/css/full_list.css
50
+ - doc/css/style.css
69
51
  - doc/file.CHANGELOG.html
52
+ - doc/file.README.html
53
+ - doc/file_list.html
70
54
  - doc/frames.html
55
+ - doc/index.html
56
+ - doc/js/app.js
57
+ - doc/js/full_list.js
58
+ - doc/js/jquery.js
59
+ - doc/method_list.html
60
+ - doc/top-level-namespace.html
61
+ - lib/unicache.rb
62
+ - lib/version.rb
63
+ - test/test_all.rb
71
64
  homepage:
72
65
  licenses:
73
66
  - Ruby
67
+ metadata: {}
74
68
  post_install_message: Check README...
75
69
  rdoc_options: []
76
70
  require_paths:
77
71
  - lib
78
72
  required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
73
  requirements:
81
- - - ! '>='
74
+ - - ">="
82
75
  - !ruby/object:Gem::Version
83
76
  version: 1.9.3
84
77
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
78
  requirements:
87
- - - ! '>='
79
+ - - ">="
88
80
  - !ruby/object:Gem::Version
89
81
  version: '0'
90
82
  requirements: []
91
83
  rubyforge_project:
92
- rubygems_version: 1.8.23
84
+ rubygems_version: 2.2.2
93
85
  signing_key:
94
- specification_version: 3
86
+ specification_version: 4
95
87
  summary: Universal purpose Cache with callback facility.
96
88
  test_files: []
97
89
  has_rdoc: