Skip to content

Commit

Permalink
added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ikod committed Aug 13, 2019
1 parent 900a5c3 commit 60f2f53
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 60 deletions.
25 changes: 11 additions & 14 deletions docs/cachetools/cache2q.html
Expand Up @@ -70,29 +70,26 @@
</ul>
</nav>
<div id="main-contents">
<h1>Module cachetools.cache2q</h1><p></p>
<h1>Module cachetools.cache2q</h1><p>2Q cache is variant of multi-level LRU cache. Original paper http://www.vldb.org/conf/1994/P439.PDF
It is adaptive, scan-resistant and can give more hits than plain LRU.
<p>This cache consists from three parts (In, Out and Main) where 'In' receive all new elements, 'Out' receives all
overflows from 'In', and 'Main' is LRU cache which hold all long-lived data.</p>
</p>
<section></section>
<section>
<h2>Aliases</h2>
<h2>Classes</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th><th>Type</th><th>Description</th>
<th>Name</th><th>Description</th>
</tr>
<tr>
<td>
<a id="TimeType" class="public" href="../cachetools/cache2q/TimeType.html">
<code>TimeType</code>
</a>
</td>
<td>
<code class="prettyprint lang-d"><span class="pln">core<wbr/></span><span class="pun">.</span><span class="pln">time<wbr/></span><span class="pun">.</span><span class="typ">MonoTimeImpl</span>!(2)</code>
<code>
<a id="Cache2Q" class="public" href="../cachetools/cache2q/Cache2Q.html">Cache2Q</a>
</code>
</td>
<td>2Q cache is variant of multi-level LRU cache. Original paper http://www.vldb.org/conf/1994/P439.PDF
It is adaptive, scan-resistant and can give more hits than plain LRU.
<p>This cache consists from three parts (In, Out and Main) where 'In' receive all new elements, 'Out' receives all
overflows from 'In', and 'Main' is LRU cache which hold all long-lived data.</p>
</td>
<td></td>
</tr>
</table>
</section>
Expand Down
47 changes: 33 additions & 14 deletions docs/cachetools/cachelru.html
Expand Up @@ -70,29 +70,48 @@
</ul>
</nav>
<div id="main-contents">
<h1>Module cachetools.cachelru</h1><p></p>
<h1>Module cachetools.cachelru</h1><p>CacheLRU contains maximum <code class="lang-d"><span class="pln">size</span></code> items
</p><section><p>Eviction policy:
<ul>evict TTL-ed entry (if TTL enabled), otherwise</ul>
<ul>if oldest entry not expired - evict oldest accessed (LRU)</ul>
</p>

<p>User can be informed about evicted entries via cache event list.
</p>


<p>Implemented as HashMap and multi-dlist.
</p>

<p><b>HashMap</b> keeps <ol><li>cached value.</li>
<li>pointer to dlist element.</li>
<li>creation time (to check expiration and purge expired entry on get() without access to dlist).</li>
</ol>
</p>

<p><b>dlist</b> keep key, creation timestamp (to check expiration) <ol><li>key, so that we can remove entries from hashmap for lists heads (AccessIndex and TimeIndex)</li>
<li>creation time, so that we can check expiration for 'TimeIndex'</li>
</ol>
Each element in dlist have two sets of double-links - first set create order by access time, second set
for creation time.
</p>
</section>

<section></section>
<section>
<h2>Aliases</h2>
<h2>Classes</h2>
<table>
<col class="caption"/>
<tr>
<th>Name</th><th>Type</th><th>Description</th>
<th>Name</th><th>Description</th>
</tr>
<tr>
<td>
<a id="TimeType" class="public" href="../cachetools/cachelru/TimeType.html">
<code>TimeType</code>
</a>
<code>
<a id="CacheLRU" class="public" href="../cachetools/cachelru/CacheLRU.html">CacheLRU</a>
</code>
</td>
<td>
<code class="prettyprint lang-d"><span class="pln">core<wbr/></span><span class="pun">.</span><span class="pln">time<wbr/></span><span class="pun">.</span><span class="typ">MonoTimeImpl</span>!(2)</code>
</td>
<td>CacheLRU contains maximum <code class="lang-d"><span class="pln">size</span></code> items
Eviction policy:
1. evict TTL-ed entry (if TTL enabled), otherwise
2. if oldest entry not expired - evict oldest accessed (LRU)
</td>
<td></td>
</tr>
</table>
</section>
Expand Down
2 changes: 1 addition & 1 deletion docs/file_hashes.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions docs/index.html
Expand Up @@ -114,15 +114,20 @@ <h1>API documentation</h1>
<a href="./cachetools/cache2q.html">cachetools.cache2q</a>
</td>
<td>

2Q cache is variant of multi-level LRU cache. Original paper http://www.vldb.org/conf/1994/P439.PDF
It is adaptive, scan-resistant and can give more hits than plain LRU.
<p>This cache consists from three parts (In, Out and Main) where 'In' receive all new elements, 'Out' receives all
overflows from 'In', and 'Main' is LRU cache which hold all long-lived data.</p>

</td>
</tr>
<tr>
<td>
<a href="./cachetools/cachelru.html">cachetools.cachelru</a>
</td>
<td>

CacheLRU contains maximum <code class="lang-d"><span class="pln">size</span></code> items

</td>
</tr>
<tr>
Expand Down
24 changes: 22 additions & 2 deletions docs/sitemap.xml
Expand Up @@ -94,9 +94,29 @@
<url><loc>http://127.0.0.1/cachetools/containers/set/Set.opBinaryRight.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/containers/set/Set.remove.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/TimeType.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.cacheEvents.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.clear.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.enableCacheEvents.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.get.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.length.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.put.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.remove.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.size.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.sizeIn.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.sizeMain.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.sizeOut.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cache2q/Cache2Q.ttl.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/TimeType.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.cacheEvents.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.clear.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.enableCacheEvents.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.get.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.put.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.remove.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.size.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/cachelru/CacheLRU.ttl.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/interfaces.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/interfaces/PutResult.html</loc></url>
<url><loc>http://127.0.0.1/cachetools/interfaces/PutResultFlag.html</loc></url>
Expand Down
24 changes: 22 additions & 2 deletions docs/symbols.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions source/cachetools/cache2q.d
@@ -1,4 +1,9 @@
///
/**
2Q cache is variant of multi-level LRU cache. Original paper http://www.vldb.org/conf/1994/P439.PDF
It is adaptive, scan-resistant and can give more hits than plain LRU.
$(P This cache consists from three parts (In, Out and Main) where 'In' receive all new elements, 'Out' receives all
overflows from 'In', and 'Main' is LRU cache which hold all long-lived data.)
**/
module cachetools.cache2q;

/// Implements Q2 cache
Expand Down Expand Up @@ -52,15 +57,10 @@ begin
end if
end
*/
/**
2Q cache is variant of multi-level LRU cache. Original paper http://www.vldb.org/conf/1994/P439.PDF
It is adaptive, scan-resistant and can give more hits than plain LRU.
$(P This cache consists from three parts (In, Out and Main) where 'In' receive all new elements, 'Out' receives all
overflows from 'In', and 'Main' is LRU cache which hold all long-lived data.)
**/

alias TimeType = MonoTimeImpl!(ClockType.coarse);

///
class Cache2Q(K, V, Allocator=Mallocator)
{
private
Expand Down
37 changes: 19 additions & 18 deletions source/cachetools/cachelru.d
@@ -1,24 +1,9 @@
///
module cachetools.cachelru;

import std.typecons;
import std.exception;
import core.time;

private import std.experimental.allocator;
private import std.experimental.allocator.mallocator : Mallocator;

private import cachetools.internal;
private import cachetools.interfaces;
private import cachetools.containers.hashmap;
private import cachetools.containers.lists;


///
/// CacheLRU contains maximum `size` items
///
/// Eviction policy:
/// 1. evict TTL-ed entry (if TTL enabled), otherwise
/// 2. if oldest entry not expired - evict oldest accessed (LRU)
/// $(UL evict TTL-ed entry (if TTL enabled), otherwise)
/// $(UL if oldest entry not expired - evict oldest accessed (LRU))
///
/// User can be informed about evicted entries via cache event list.
///
Expand All @@ -38,9 +23,25 @@ private import cachetools.containers.lists;
/// Each element in dlist have two sets of double-links - first set create order by access time, second set
/// for creation time.
///
module cachetools.cachelru;

import std.typecons;
import std.exception;
import core.time;

private import std.experimental.allocator;
private import std.experimental.allocator.mallocator : Mallocator;

private import cachetools.internal;
private import cachetools.interfaces;
private import cachetools.containers.hashmap;
private import cachetools.containers.lists;



alias TimeType = MonoTimeImpl!(ClockType.coarse);

///
class CacheLRU(K, V, Allocator = Mallocator)
{
private
Expand Down

0 comments on commit 60f2f53

Please sign in to comment.