--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Documentation/Source/eric6.E5Utilities.E5Cache.html Tue Oct 03 19:37:44 2017 +0200 @@ -0,0 +1,251 @@ +<!DOCTYPE html> +<html><head> +<title>eric6.E5Utilities.E5Cache</title> +<meta charset="UTF-8"> +<style> +body { + background: #EDECE6; + margin: 0em 1em 10em 1em; + color: black; +} + +h1 { color: white; background: #85774A; } +h2 { color: white; background: #85774A; } +h3 { color: white; background: #9D936E; } +h4 { color: white; background: #9D936E; } + +a { color: #BA6D36; } + +</style> +</head> +<body><a NAME="top" ID="top"></a> +<h1>eric6.E5Utilities.E5Cache</h1> +<p> +Module implementing classes used for caching objects. +</p> +<h3>Global Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Classes</h3> +<table> +<tr> +<td><a href="#E5Cache">E5Cache</a></td> +<td>Class implementing a LRU cache of a specific size.</td> +</tr> +</table> +<h3>Functions</h3> +<table> +<tr><td>None</td></tr> +</table> +<hr /><hr /> +<a NAME="E5Cache" ID="E5Cache"></a> +<h2>E5Cache</h2> +<p> + Class implementing a LRU cache of a specific size. +</p><p> + If the maximum number of entries is exceeded, the least recently used item + is removed from the cache. A cache hit moves the entry to the front of the + cache. +</p> +<h3>Derived from</h3> +object +<h3>Class Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Class Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> +<table> +<tr> +<td><a href="#E5Cache.__init__">E5Cache</a></td> +<td>Constructor</td> +</tr><tr> +<td><a href="#E5Cache.__adjustToSize">__adjustToSize</a></td> +<td>Private method to adjust the cache to its size.</td> +</tr><tr> +<td><a href="#E5Cache.__moveLast">__moveLast</a></td> +<td>Private method to move a cached item to the MRU position.</td> +</tr><tr> +<td><a href="#E5Cache.add">add</a></td> +<td>Public method to add an item to the cache.</td> +</tr><tr> +<td><a href="#E5Cache.clear">clear</a></td> +<td>Public method to clear the cache.</td> +</tr><tr> +<td><a href="#E5Cache.get">get</a></td> +<td>Public method to get an entry from the cache given its key.</td> +</tr><tr> +<td><a href="#E5Cache.getSize">getSize</a></td> +<td>Public method to get the size of the cache.</td> +</tr><tr> +<td><a href="#E5Cache.info">info</a></td> +<td>Public method to get some information about the cache.</td> +</tr><tr> +<td><a href="#E5Cache.length">length</a></td> +<td>Public method to get the current length of the cache.</td> +</tr><tr> +<td><a href="#E5Cache.remove">remove</a></td> +<td>Public method to remove an item from the cache.</td> +</tr><tr> +<td><a href="#E5Cache.reset">reset</a></td> +<td>Public method to reset the cache.</td> +</tr><tr> +<td><a href="#E5Cache.setSize">setSize</a></td> +<td>Public method to change the size of the cache.</td> +</tr> +</table> +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<a NAME="E5Cache.__init__" ID="E5Cache.__init__"></a> +<h4>E5Cache (Constructor)</h4> +<b>E5Cache</b>(<i>size=100</i>) +<p> + Constructor +</p><dl> +<dt><i>size</i> (int)</dt> +<dd> +maximum number of entries that may be stored in the cache +</dd> +</dl><a NAME="E5Cache.__adjustToSize" ID="E5Cache.__adjustToSize"></a> +<h4>E5Cache.__adjustToSize</h4> +<b>__adjustToSize</b>(<i></i>) +<p> + Private method to adjust the cache to its size. +</p><a NAME="E5Cache.__moveLast" ID="E5Cache.__moveLast"></a> +<h4>E5Cache.__moveLast</h4> +<b>__moveLast</b>(<i>key</i>) +<p> + Private method to move a cached item to the MRU position. +</p><dl> +<dt><i>key</i> (any hashable type that can be used as a dict key)</dt> +<dd> +key of the item to be retrieved +</dd> +</dl><a NAME="E5Cache.add" ID="E5Cache.add"></a> +<h4>E5Cache.add</h4> +<b>add</b>(<i>key, item</i>) +<p> + Public method to add an item to the cache. +</p><p> + If the key is already in use, the cached item is replaced by the new + one given and is moved to the MRU position +</p><dl> +<dt><i>key</i> (any hashable type that can be used as a dict key)</dt> +<dd> +key of the item to be retrieved +</dd><dt><i>item</i> (object)</dt> +<dd> +item to be cached under the given key +</dd> +</dl><a NAME="E5Cache.clear" ID="E5Cache.clear"></a> +<h4>E5Cache.clear</h4> +<b>clear</b>(<i></i>) +<p> + Public method to clear the cache. +</p><a NAME="E5Cache.get" ID="E5Cache.get"></a> +<h4>E5Cache.get</h4> +<b>get</b>(<i>key</i>) +<p> + Public method to get an entry from the cache given its key. +</p><p> + If the key is present in the cache, it is moved to the MRU position. +</p><dl> +<dt><i>key</i> (any hashable type that can be used as a dict key)</dt> +<dd> +key of the item to be retrieved +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +cached item for the given key or None, if the key is not + present +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +object or None +</dd> +</dl><a NAME="E5Cache.getSize" ID="E5Cache.getSize"></a> +<h4>E5Cache.getSize</h4> +<b>getSize</b>(<i></i>) +<p> + Public method to get the size of the cache. +</p><dl> +<dt>Returns:</dt> +<dd> +maximum number of entries of the cache +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +int +</dd> +</dl><a NAME="E5Cache.info" ID="E5Cache.info"></a> +<h4>E5Cache.info</h4> +<b>info</b>(<i></i>) +<p> + Public method to get some information about the cache. +</p><dl> +<dt>Returns:</dt> +<dd> +dictionary containing the cache info +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +dict (with keys "hits", "misses", "maxsize", "currsize") +</dd> +</dl><a NAME="E5Cache.length" ID="E5Cache.length"></a> +<h4>E5Cache.length</h4> +<b>length</b>(<i></i>) +<p> + Public method to get the current length of the cache. +</p><dl> +<dt>Returns:</dt> +<dd> +current length of the cache +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +int +</dd> +</dl><a NAME="E5Cache.remove" ID="E5Cache.remove"></a> +<h4>E5Cache.remove</h4> +<b>remove</b>(<i>key</i>) +<p> + Public method to remove an item from the cache. +</p><dl> +<dt><i>key</i> (any hashable type that can be used as a dict key)</dt> +<dd> +key of the item to be retrieved +</dd> +</dl><a NAME="E5Cache.reset" ID="E5Cache.reset"></a> +<h4>E5Cache.reset</h4> +<b>reset</b>(<i></i>) +<p> + Public method to reset the cache. +</p><p> + This is like clear() but sets the various counters to their initial + value as well. +</p><a NAME="E5Cache.setSize" ID="E5Cache.setSize"></a> +<h4>E5Cache.setSize</h4> +<b>setSize</b>(<i>newSize</i>) +<p> + Public method to change the size of the cache. +</p><dl> +<dt><i>newSize</i> (int)</dt> +<dd> +maximum number of entries that may be stored in the + cache +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /> +</body></html> \ No newline at end of file