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.

802 lines
26 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>diskv - 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 diskv</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/peterbourgon/diskv"</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. </div>
  68. </div>
  69. <div id="pkg-index" class="toggleVisible">
  70. <div class="collapsed">
  71. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  72. </div>
  73. <div class="expanded">
  74. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  75. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  76. <div id="manual-nav">
  77. <dl>
  78. <dd><a href="index.html#BTreeIndex">type BTreeIndex</a></dd>
  79. <dd>&nbsp; &nbsp; <a href="index.html#BTreeIndex.Delete">func (i *BTreeIndex) Delete(key string)</a></dd>
  80. <dd>&nbsp; &nbsp; <a href="index.html#BTreeIndex.Initialize">func (i *BTreeIndex) Initialize(less LessFunction, keys &lt;-chan string)</a></dd>
  81. <dd>&nbsp; &nbsp; <a href="index.html#BTreeIndex.Insert">func (i *BTreeIndex) Insert(key string)</a></dd>
  82. <dd>&nbsp; &nbsp; <a href="index.html#BTreeIndex.Keys">func (i *BTreeIndex) Keys(from string, n int) []string</a></dd>
  83. <dd><a href="index.html#Compression">type Compression</a></dd>
  84. <dd>&nbsp; &nbsp; <a href="index.html#NewGzipCompression">func NewGzipCompression() Compression</a></dd>
  85. <dd>&nbsp; &nbsp; <a href="index.html#NewGzipCompressionLevel">func NewGzipCompressionLevel(level int) Compression</a></dd>
  86. <dd>&nbsp; &nbsp; <a href="index.html#NewZlibCompression">func NewZlibCompression() Compression</a></dd>
  87. <dd>&nbsp; &nbsp; <a href="index.html#NewZlibCompressionLevel">func NewZlibCompressionLevel(level int) Compression</a></dd>
  88. <dd>&nbsp; &nbsp; <a href="index.html#NewZlibCompressionLevelDict">func NewZlibCompressionLevelDict(level int, dict []byte) Compression</a></dd>
  89. <dd><a href="index.html#Diskv">type Diskv</a></dd>
  90. <dd>&nbsp; &nbsp; <a href="index.html#New">func New(o Options) *Diskv</a></dd>
  91. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.Erase">func (d *Diskv) Erase(key string) error</a></dd>
  92. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.EraseAll">func (d *Diskv) EraseAll() error</a></dd>
  93. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.Has">func (d *Diskv) Has(key string) bool</a></dd>
  94. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.Import">func (d *Diskv) Import(srcFilename, dstKey string, move bool) (err error)</a></dd>
  95. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.Keys">func (d *Diskv) Keys(cancel &lt;-chan struct{}) &lt;-chan string</a></dd>
  96. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.KeysPrefix">func (d *Diskv) KeysPrefix(prefix string, cancel &lt;-chan struct{}) &lt;-chan string</a></dd>
  97. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.Read">func (d *Diskv) Read(key string) ([]byte, error)</a></dd>
  98. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.ReadStream">func (d *Diskv) ReadStream(key string, direct bool) (io.ReadCloser, error)</a></dd>
  99. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.Write">func (d *Diskv) Write(key string, val []byte) error</a></dd>
  100. <dd>&nbsp; &nbsp; <a href="index.html#Diskv.WriteStream">func (d *Diskv) WriteStream(key string, r io.Reader, sync bool) error</a></dd>
  101. <dd><a href="index.html#Index">type Index</a></dd>
  102. <dd><a href="index.html#LessFunction">type LessFunction</a></dd>
  103. <dd><a href="index.html#Options">type Options</a></dd>
  104. <dd><a href="index.html#TransformFunction">type TransformFunction</a></dd>
  105. </dl>
  106. </div><!-- #manual-nav -->
  107. <h4>Package files</h4>
  108. <p>
  109. <span style="font-size:90%">
  110. <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go">compression.go</a>
  111. <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go">diskv.go</a>
  112. <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go">index.go</a>
  113. </span>
  114. </p>
  115. </div><!-- .expanded -->
  116. </div><!-- #pkg-index -->
  117. <div id="pkg-callgraph" class="toggle" style="display: none">
  118. <div class="collapsed">
  119. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  120. </div> <!-- .expanded -->
  121. <div class="expanded">
  122. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  123. <p>
  124. In the call graph viewer below, each node
  125. is a function belonging to this package
  126. and its children are the functions it
  127. calls&mdash;perhaps dynamically.
  128. </p>
  129. <p>
  130. The root nodes are the entry points of the
  131. package: functions that may be called from
  132. outside the package.
  133. There may be non-exported or anonymous
  134. functions among them if they are called
  135. dynamically from another package.
  136. </p>
  137. <p>
  138. Click a node to visit that function's source code.
  139. From there you can visit its callers by
  140. clicking its declaring <code>func</code>
  141. token.
  142. </p>
  143. <p>
  144. Functions may be omitted if they were
  145. determined to be unreachable in the
  146. particular programs or tests that were
  147. analyzed.
  148. </p>
  149. <!-- Zero means show all package entry points. -->
  150. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  151. </div>
  152. </div> <!-- #pkg-callgraph -->
  153. <h2 id="BTreeIndex">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=864:932#L24">BTreeIndex</a></h2>
  154. <pre>type BTreeIndex struct {
  155. <a href="../../../sync/index.html">sync</a>.<a href="../../../sync/index.html#RWMutex">RWMutex</a>
  156. <a href="index.html#LessFunction">LessFunction</a>
  157. *<a href="../../google/btree/index.html">btree</a>.<a href="../../google/btree/index.html#BTree">BTree</a>
  158. }</pre>
  159. <p>
  160. BTreeIndex is an implementation of the Index interface using google/btree.
  161. </p>
  162. <h3 id="BTreeIndex.Delete">func (*BTreeIndex) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=1580:1619#L50">Delete</a></h3>
  163. <pre>func (i *<a href="index.html#BTreeIndex">BTreeIndex</a>) Delete(key <a href="../../../builtin/index.html#string">string</a>)</pre>
  164. <p>
  165. Delete removes the given key (only) from the BTree tree.
  166. </p>
  167. <h3 id="BTreeIndex.Initialize">func (*BTreeIndex) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=1084:1154#L32">Initialize</a></h3>
  168. <pre>func (i *<a href="index.html#BTreeIndex">BTreeIndex</a>) Initialize(less <a href="index.html#LessFunction">LessFunction</a>, keys &lt;-chan <a href="../../../builtin/index.html#string">string</a>)</pre>
  169. <p>
  170. Initialize populates the BTree tree with data from the keys channel,
  171. according to the passed less function. It&#39;s destructive to the BTreeIndex.
  172. </p>
  173. <h3 id="BTreeIndex.Insert">func (*BTreeIndex) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=1302:1341#L40">Insert</a></h3>
  174. <pre>func (i *<a href="index.html#BTreeIndex">BTreeIndex</a>) Insert(key <a href="../../../builtin/index.html#string">string</a>)</pre>
  175. <p>
  176. Insert inserts the given key (only) into the BTree tree.
  177. </p>
  178. <h3 id="BTreeIndex.Keys">func (*BTreeIndex) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=2059:2113#L63">Keys</a></h3>
  179. <pre>func (i *<a href="index.html#BTreeIndex">BTreeIndex</a>) Keys(from <a href="../../../builtin/index.html#string">string</a>, n <a href="../../../builtin/index.html#int">int</a>) []<a href="../../../builtin/index.html#string">string</a></pre>
  180. <p>
  181. Keys yields a maximum of n keys in order. If the passed &#39;from&#39; key is empty,
  182. Keys will return the first n keys. If the passed &#39;from&#39; key is non-empty, the
  183. first key in the returned slice will be the key that immediately follows the
  184. passed key, in key order.
  185. </p>
  186. <h2 id="Compression">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go?s=479:602#L6">Compression</a></h2>
  187. <pre>type Compression interface {
  188. Writer(dst <a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#Writer">Writer</a>) (<a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#WriteCloser">WriteCloser</a>, <a href="../../../builtin/index.html#error">error</a>)
  189. Reader(src <a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#Reader">Reader</a>) (<a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#ReadCloser">ReadCloser</a>, <a href="../../../builtin/index.html#error">error</a>)
  190. }</pre>
  191. <p>
  192. Compression is an interface that Diskv uses to implement compression of
  193. data. Writer takes a destination io.Writer and returns a WriteCloser that
  194. compresses all data written through it. Reader takes a source io.Reader and
  195. returns a ReadCloser that decompresses all data read through it. You may
  196. define these methods on your own type, or use one of the NewCompression
  197. helpers.
  198. </p>
  199. <h3 id="NewGzipCompression">func <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go?s=660:697#L12">NewGzipCompression</a></h3>
  200. <pre>func NewGzipCompression() <a href="index.html#Compression">Compression</a></pre>
  201. <p>
  202. NewGzipCompression returns a Gzip-based Compression.
  203. </p>
  204. <h3 id="NewGzipCompressionLevel">func <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go?s=843:894#L17">NewGzipCompressionLevel</a></h3>
  205. <pre>func NewGzipCompressionLevel(level <a href="../../../builtin/index.html#int">int</a>) <a href="index.html#Compression">Compression</a></pre>
  206. <p>
  207. NewGzipCompressionLevel returns a Gzip-based Compression with the given level.
  208. </p>
  209. <h3 id="NewZlibCompression">func <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go?s=1155:1192#L25">NewZlibCompression</a></h3>
  210. <pre>func NewZlibCompression() <a href="index.html#Compression">Compression</a></pre>
  211. <p>
  212. NewZlibCompression returns a Zlib-based Compression.
  213. </p>
  214. <h3 id="NewZlibCompressionLevel">func <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go?s=1338:1389#L30">NewZlibCompressionLevel</a></h3>
  215. <pre>func NewZlibCompressionLevel(level <a href="../../../builtin/index.html#int">int</a>) <a href="index.html#Compression">Compression</a></pre>
  216. <p>
  217. NewZlibCompressionLevel returns a Zlib-based Compression with the given level.
  218. </p>
  219. <h3 id="NewZlibCompressionLevelDict">func <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/compression.go?s=1563:1631#L36">NewZlibCompressionLevelDict</a></h3>
  220. <pre>func NewZlibCompressionLevelDict(level <a href="../../../builtin/index.html#int">int</a>, dict []<a href="../../../builtin/index.html#byte">byte</a>) <a href="index.html#Compression">Compression</a></pre>
  221. <p>
  222. NewZlibCompressionLevelDict returns a Zlib-based Compression with the given
  223. level, based on the given dictionary.
  224. </p>
  225. <h2 id="Diskv">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=1474:1575#L48">Diskv</a></h2>
  226. <pre>type Diskv struct {
  227. <a href="index.html#Options">Options</a>
  228. <span class="comment">// contains filtered or unexported fields</span>
  229. }</pre>
  230. <p>
  231. Diskv implements the Diskv interface. You shouldn&#39;t construct Diskv
  232. structures directly; instead, use the New constructor.
  233. </p>
  234. <h3 id="New">func <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=1744:1770#L58">New</a></h3>
  235. <pre>func New(o <a href="index.html#Options">Options</a>) *<a href="index.html#Diskv">Diskv</a></pre>
  236. <p>
  237. New returns an initialized Diskv structure, ready to use.
  238. If the path identified by baseDir already contains data,
  239. it will be accessible, but not yet cached.
  240. </p>
  241. <h3 id="Diskv.Erase">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=9023:9062#L344">Erase</a></h3>
  242. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) Erase(key <a href="../../../builtin/index.html#string">string</a>) <a href="../../../builtin/index.html#error">error</a></pre>
  243. <p>
  244. Erase synchronously erases the given key from the disk and the cache.
  245. </p>
  246. <h3 id="Diskv.EraseAll">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=9839:9871#L378">EraseAll</a></h3>
  247. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) EraseAll() <a href="../../../builtin/index.html#error">error</a></pre>
  248. <p>
  249. EraseAll will delete all of the data from the store, both in the cache and on
  250. the disk. Note that EraseAll doesn&#39;t distinguish diskv-related data from non-
  251. diskv-related data. Care should be taken to always specify a diskv base
  252. directory that is exclusively for diskv data.
  253. </p>
  254. <h3 id="Diskv.Has">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=10041:10077#L387">Has</a></h3>
  255. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) Has(key <a href="../../../builtin/index.html#string">string</a>) <a href="../../../builtin/index.html#bool">bool</a></pre>
  256. <p>
  257. Has returns true if the given key exists.
  258. </p>
  259. <h3 id="Diskv.Import">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=4491:4564#L163">Import</a></h3>
  260. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) Import(srcFilename, dstKey <a href="../../../builtin/index.html#string">string</a>, move <a href="../../../builtin/index.html#bool">bool</a>) (err <a href="../../../builtin/index.html#error">error</a>)</pre>
  261. <p>
  262. Import imports the source file into diskv under the destination key. If the
  263. destination key already exists, it&#39;s overwritten. If move is true, the
  264. source file is removed after a successful import.
  265. </p>
  266. <h3 id="Diskv.Keys">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=10507:10565#L410">Keys</a></h3>
  267. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) Keys(cancel &lt;-chan struct{}) &lt;-chan <a href="../../../builtin/index.html#string">string</a></pre>
  268. <p>
  269. Keys returns a channel that will yield every key accessible by the store,
  270. in undefined order. If a cancel channel is provided, closing it will
  271. terminate and close the keys channel.
  272. </p>
  273. <h3 id="Diskv.KeysPrefix">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=10895:10974#L418">KeysPrefix</a></h3>
  274. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) KeysPrefix(prefix <a href="../../../builtin/index.html#string">string</a>, cancel &lt;-chan struct{}) &lt;-chan <a href="../../../builtin/index.html#string">string</a></pre>
  275. <p>
  276. KeysPrefix returns a channel that will yield every key accessible by the
  277. store with the given prefix, in undefined order. If a cancel channel is
  278. provided, closing it will terminate and close the keys channel. If the
  279. provided prefix is the empty string, all keys will be yielded.
  280. </p>
  281. <h3 id="Diskv.Read">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=5552:5600#L207">Read</a></h3>
  282. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) Read(key <a href="../../../builtin/index.html#string">string</a>) ([]<a href="../../../builtin/index.html#byte">byte</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  283. <p>
  284. Read reads the key and returns the value.
  285. If the key is available in the cache, Read won&#39;t touch the disk.
  286. If the key is not in the cache, Read will have the side-effect of
  287. lazily caching the value.
  288. </p>
  289. <h3 id="Diskv.ReadStream">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=6276:6350#L226">ReadStream</a></h3>
  290. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) ReadStream(key <a href="../../../builtin/index.html#string">string</a>, direct <a href="../../../builtin/index.html#bool">bool</a>) (<a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#ReadCloser">ReadCloser</a>, <a href="../../../builtin/index.html#error">error</a>)</pre>
  291. <p>
  292. ReadStream reads the key and returns the value (data) as an io.ReadCloser.
  293. If the value is cached from a previous read, and direct is false,
  294. ReadStream will use the cached value. Otherwise, it will return a handle to
  295. the file on disk, and cache the data on read.
  296. </p>
  297. <p>
  298. If direct is true, ReadStream will lazily delete any cached value for the
  299. key, and return a direct handle to the file on disk.
  300. </p>
  301. <p>
  302. If compression is enabled, ReadStream taps into the io.Reader stream prior
  303. to decompression, and caches the compressed data.
  304. </p>
  305. <h3 id="Diskv.Write">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=2430:2481#L88">Write</a></h3>
  306. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) Write(key <a href="../../../builtin/index.html#string">string</a>, val []<a href="../../../builtin/index.html#byte">byte</a>) <a href="../../../builtin/index.html#error">error</a></pre>
  307. <p>
  308. Write synchronously writes the key-value pair to disk, making it immediately
  309. available for reads. Write relies on the filesystem to perform an eventual
  310. sync to physical media. If you need stronger guarantees, see WriteStream.
  311. </p>
  312. <h3 id="Diskv.WriteStream">func (*Diskv) <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=2808:2877#L97">WriteStream</a></h3>
  313. <pre>func (d *<a href="index.html#Diskv">Diskv</a>) WriteStream(key <a href="../../../builtin/index.html#string">string</a>, r <a href="../../../io/index.html">io</a>.<a href="../../../io/index.html#Reader">Reader</a>, sync <a href="../../../builtin/index.html#bool">bool</a>) <a href="../../../builtin/index.html#error">error</a></pre>
  314. <p>
  315. WriteStream writes the data represented by the io.Reader to the disk, under
  316. the provided key. If sync is true, WriteStream performs an explicit sync on
  317. the file as soon as it&#39;s written.
  318. </p>
  319. <p>
  320. bytes.Buffer provides io.Reader semantics for basic data types.
  321. </p>
  322. <h2 id="Index">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=151:301#L1">Index</a></h2>
  323. <pre>type Index interface {
  324. Initialize(less <a href="index.html#LessFunction">LessFunction</a>, keys &lt;-chan <a href="../../../builtin/index.html#string">string</a>)
  325. Insert(key <a href="../../../builtin/index.html#string">string</a>)
  326. Delete(key <a href="../../../builtin/index.html#string">string</a>)
  327. Keys(from <a href="../../../builtin/index.html#string">string</a>, n <a href="../../../builtin/index.html#int">int</a>) []<a href="../../../builtin/index.html#string">string</a>
  328. }</pre>
  329. <p>
  330. Index is a generic interface for things that can
  331. provide an ordered list of keys.
  332. </p>
  333. <h2 id="LessFunction">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/index.go?s=379:422#L9">LessFunction</a></h2>
  334. <pre>type LessFunction func(<a href="../../../builtin/index.html#string">string</a>, <a href="../../../builtin/index.html#string">string</a>) <a href="../../../builtin/index.html#bool">bool</a></pre>
  335. <p>
  336. LessFunction is used to initialize an Index of keys in a specific order.
  337. </p>
  338. <h2 id="Options">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=1117:1343#L33">Options</a></h2>
  339. <pre>type Options struct {
  340. BasePath <a href="../../../builtin/index.html#string">string</a>
  341. Transform <a href="index.html#TransformFunction">TransformFunction</a>
  342. CacheSizeMax <a href="../../../builtin/index.html#uint64">uint64</a> <span class="comment">// bytes</span>
  343. PathPerm <a href="../../../os/index.html">os</a>.<a href="../../../os/index.html#FileMode">FileMode</a>
  344. FilePerm <a href="../../../os/index.html">os</a>.<a href="../../../os/index.html#FileMode">FileMode</a>
  345. Index <a href="index.html#Index">Index</a>
  346. IndexLess <a href="index.html#LessFunction">LessFunction</a>
  347. Compression <a href="index.html#Compression">Compression</a>
  348. }</pre>
  349. <p>
  350. Options define a set of properties that dictate Diskv behavior.
  351. All values are optional.
  352. </p>
  353. <h2 id="TransformFunction">type <a href="http://localhost:6060/src/github.com/peterbourgon/diskv/diskv.go?s=974:1020#L29">TransformFunction</a></h2>
  354. <pre>type TransformFunction func(s <a href="../../../builtin/index.html#string">string</a>) []<a href="../../../builtin/index.html#string">string</a></pre>
  355. <p>
  356. TransformFunction transforms a key into a slice of strings, with each
  357. element in the slice representing a directory in the file path where the
  358. key&#39;s entry will eventually be stored.
  359. </p>
  360. <p>
  361. For example, if TransformFunc transforms &#34;abcdef&#34; to [&#34;ab&#34;, &#34;cde&#34;, &#34;f&#34;],
  362. the final location of the data file will be &lt;basedir&gt;/ab/cde/f/abcdef
  363. </p>
  364. <h2 id="pkg-subdirectories">Subdirectories</h2>
  365. <div class="pkg-dir">
  366. <table>
  367. <tr>
  368. <th class="pkg-name">Name</th>
  369. <th class="pkg-synopsis">Synopsis</th>
  370. </tr>
  371. <tr>
  372. <td colspan="2"><a href="../index.html">..</a></td>
  373. </tr>
  374. <tr>
  375. <td class="pkg-name" style="padding-left: 0px;">
  376. <a href="examples/index.html">examples</a>
  377. </td>
  378. <td class="pkg-synopsis">
  379. </td>
  380. </tr>
  381. <tr>
  382. <td class="pkg-name" style="padding-left: 20px;">
  383. <a href="examples/content-addressable-store/index.html">content-addressable-store</a>
  384. </td>
  385. <td class="pkg-synopsis">
  386. </td>
  387. </tr>
  388. <tr>
  389. <td class="pkg-name" style="padding-left: 20px;">
  390. <a href="examples/super-simple-store/index.html">super-simple-store</a>
  391. </td>
  392. <td class="pkg-synopsis">
  393. </td>
  394. </tr>
  395. </table>
  396. </div>
  397. <div id="footer">
  398. Build version go1.6.<br>
  399. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  400. the content of this page is licensed under the
  401. Creative Commons Attribution 3.0 License,
  402. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  403. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  404. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  405. </div>
  406. </div><!-- .container -->
  407. </div><!-- #page -->
  408. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  409. <script type="text/javascript" src="../../../../lib/godoc/jquery.js"></script>
  410. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.js"></script>
  411. <script type="text/javascript" src="../../../../lib/godoc/jquery.treeview.edit.js"></script>
  412. <script type="text/javascript" src="../../../../lib/godoc/godocs.js"></script>
  413. </body>
  414. </html>