You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

351 lines
10 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>lrucache - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package lrucache</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "github.com/die-net/lrucache"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. <dd><a href="index.html#pkg-subdirectories">Subdirectories</a></dd>
  58. </dl>
  59. </div>
  60. <!-- The package's Name is printed as title by the top-level template -->
  61. <div id="pkg-overview" class="toggleVisible">
  62. <div class="collapsed">
  63. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  64. </div>
  65. <div class="expanded">
  66. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  67. <p>
  68. Package lrucache provides a byte-size-limited implementation of
  69. httpcache.Cache that stores data in memory.
  70. </p>
  71. </div>
  72. </div>
  73. <div id="pkg-index" class="toggleVisible">
  74. <div class="collapsed">
  75. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  76. </div>
  77. <div class="expanded">
  78. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  79. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  80. <div id="manual-nav">
  81. <dl>
  82. <dd><a href="index.html#LruCache">type LruCache</a></dd>
  83. <dd>&nbsp; &nbsp; <a href="index.html#New">func New(maxSize int64, maxAge int64) *LruCache</a></dd>
  84. <dd>&nbsp; &nbsp; <a href="index.html#LruCache.Delete">func (c *LruCache) Delete(key string)</a></dd>
  85. <dd>&nbsp; &nbsp; <a href="index.html#LruCache.Get">func (c *LruCache) Get(key string) ([]byte, bool)</a></dd>
  86. <dd>&nbsp; &nbsp; <a href="index.html#LruCache.Set">func (c *LruCache) Set(key string, value []byte)</a></dd>
  87. <dd>&nbsp; &nbsp; <a href="index.html#LruCache.Size">func (c *LruCache) Size() int64</a></dd>
  88. </dl>
  89. </div><!-- #manual-nav -->
  90. <h4>Package files</h4>
  91. <p>
  92. <span style="font-size:90%">
  93. <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go">lrucache.go</a>
  94. </span>
  95. </p>
  96. </div><!-- .expanded -->
  97. </div><!-- #pkg-index -->
  98. <div id="pkg-callgraph" class="toggle" style="display: none">
  99. <div class="collapsed">
  100. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  101. </div> <!-- .expanded -->
  102. <div class="expanded">
  103. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  104. <p>
  105. In the call graph viewer below, each node
  106. is a function belonging to this package
  107. and its children are the functions it
  108. calls&mdash;perhaps dynamically.
  109. </p>
  110. <p>
  111. The root nodes are the entry points of the
  112. package: functions that may be called from
  113. outside the package.
  114. There may be non-exported or anonymous
  115. functions among them if they are called
  116. dynamically from another package.
  117. </p>
  118. <p>
  119. Click a node to visit that function's source code.
  120. From there you can visit its callers by
  121. clicking its declaring <code>func</code>
  122. token.
  123. </p>
  124. <p>
  125. Functions may be omitted if they were
  126. determined to be unreachable in the
  127. particular programs or tests that were
  128. analyzed.
  129. </p>
  130. <!-- Zero means show all package entry points. -->
  131. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  132. </div>
  133. </div> <!-- #pkg-callgraph -->
  134. <h2 id="LruCache">type <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go?s=454:615#L5">LruCache</a></h2>
  135. <pre>type LruCache struct {
  136. MaxSize <a href="../../../builtin/index.html#int64">int64</a>
  137. MaxAge <a href="../../../builtin/index.html#int64">int64</a>
  138. <span class="comment">// contains filtered or unexported fields</span>
  139. }</pre>
  140. <p>
  141. LruCache is a thread-safe, in-memory httpcache.Cache that evicts the
  142. least recently used entries from memory when either MaxSize (in bytes)
  143. limit would be exceeded or (if set) the entries are older than MaxAge (in
  144. seconds). Use the New constructor to create one.
  145. </p>
  146. <h3 id="New">func <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go?s=771:818#L18">New</a></h3>
  147. <pre>func New(maxSize <a href="../../../builtin/index.html#int64">int64</a>, maxAge <a href="../../../builtin/index.html#int64">int64</a>) *<a href="index.html#LruCache">LruCache</a></pre>
  148. <p>
  149. New creates an LruCache that will restrict itself to maxSize bytes of
  150. memory. If maxAge &gt; 0, entries will also be expired after maxAge
  151. seconds.
  152. </p>
  153. <h3 id="LruCache.Delete">func (*LruCache) <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go?s=2155:2192#L82">Delete</a></h3>
  154. <pre>func (c *<a href="index.html#LruCache">LruCache</a>) Delete(key <a href="../../../builtin/index.html#string">string</a>)</pre>
  155. <p>
  156. Delete removes the value associated with a key.
  157. </p>
  158. <h3 id="LruCache.Get">func (*LruCache) <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go?s=1070:1119#L31">Get</a></h3>
  159. <pre>func (c *<a href="index.html#LruCache">LruCache</a>) Get(key <a href="../../../builtin/index.html#string">string</a>) ([]<a href="../../../builtin/index.html#byte">byte</a>, <a href="../../../builtin/index.html#bool">bool</a>)</pre>
  160. <p>
  161. Get returns the []byte representation of a cached response and a bool
  162. set to true if the key was found.
  163. </p>
  164. <h3 id="LruCache.Set">func (*LruCache) <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go?s=1613:1661#L56">Set</a></h3>
  165. <pre>func (c *<a href="index.html#LruCache">LruCache</a>) Set(key <a href="../../../builtin/index.html#string">string</a>, value []<a href="../../../builtin/index.html#byte">byte</a>)</pre>
  166. <p>
  167. Set stores the []byte representation of a response for a given key.
  168. </p>
  169. <h3 id="LruCache.Size">func (*LruCache) <a href="http://localhost:6060/src/github.com/die-net/lrucache/lrucache.go?s=2350:2381#L93">Size</a></h3>
  170. <pre>func (c *<a href="index.html#LruCache">LruCache</a>) Size() <a href="../../../builtin/index.html#int64">int64</a></pre>
  171. <p>
  172. Size returns the estimated current memory usage of LruCache.
  173. </p>
  174. <h2 id="pkg-subdirectories">Subdirectories</h2>
  175. <div class="pkg-dir">
  176. <table>
  177. <tr>
  178. <th class="pkg-name">Name</th>
  179. <th class="pkg-synopsis">Synopsis</th>
  180. </tr>
  181. <tr>
  182. <td colspan="2"><a href="../index.html">..</a></td>
  183. </tr>
  184. <tr>
  185. <td class="pkg-name" style="padding-left: 0px;">
  186. <a href="twotier/index.html">twotier</a>
  187. </td>
  188. <td class="pkg-synopsis">
  189. Package twotier provides a wrapper for two httpcache.Cache instances, allowing you to use both a small and fast cache for popular objects and fall back to a larger and slower cache for less popular ones.
  190. </td>
  191. </tr>
  192. </table>
  193. </div>
  194. <div id="footer">
  195. Build version go1.6.<br>
  196. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  197. the content of this page is licensed under the
  198. Creative Commons Attribution 3.0 License,
  199. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  200. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  201. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  202. </div>
  203. </div><!-- .container -->
  204. </div><!-- #page -->
  205. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  206. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  207. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  208. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  209. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  210. </body>
  211. </html>