• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/db-4.8.30/docs/api_reference/C/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>DB-&gt;set_cachesize()</title>
7    <link rel="stylesheet" href="apiReference.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB C API Reference" />
10    <link rel="up" href="db.html" title="Chapter��2.�� The DB Handle" />
11    <link rel="prev" href="dbset_bt_prefix.html" title="DB-&gt;set_bt_prefix()" />
12    <link rel="next" href="dbset_create_dir.html" title="DB-&gt;set_create_dir()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">DB-&gt;set_cachesize()</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="dbset_bt_prefix.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��2.��
23                The DB Handle
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="dbset_create_dir.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="dbset_cachesize"></a>DB-&gt;set_cachesize()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db.h&gt;
39
40int
41DB-&gt;set_cachesize(DB *db,
42    u_int32_t gbytes, u_int32_t bytes, int ncache);  </pre>
43      <p>
44         Set the size of the shared memory buffer pool -- that is, the cache.
45         The cache should be the size of the normal working data set of the
46         application, with some small amount of additional memory for unusual
47         situations.  (Note: the working set is not the same as the number of
48         pages accessed simultaneously, and is usually much larger.)
49    </p>
50      <p>
51         The default cache size is 256KB, and may not be specified as less than
52         20KB.  Any cache size less than 500MB is automatically increased by
53         25% to account for buffer pool overhead; cache sizes larger than 500MB
54         are used as specified.  The maximum size of a single cache is 4GB on
55         32-bit systems and 10TB on 64-bit systems.  (All sizes are in
56         powers-of-two, that is, 256KB is 2^18 not 256,000.) For information on
57         tuning the Berkeley DB cache size, see <a href="../../programmer_reference/general_am_conf.html#am_conf_cachesize" class="olink">Selecting a cache size</a>.
58    </p>
59      <p>
60         It is possible to specify caches to Berkeley DB large enough they
61         cannot be allocated contiguously on some architectures.  For example,
62         some releases of Solaris limit the amount of memory that may be
63         allocated contiguously by a process.  If <span class="bold"><strong>ncache</strong></span> is 0 or 1, the cache will be allocated
64         contiguously in memory.  If it is greater than 1, the cache will be
65         split across <span class="bold"><strong>ncache</strong></span> separate regions,
66         where the <span class="bold"><strong>region size</strong></span> is equal to the
67         initial cache size divided by <span class="bold"><strong>ncache</strong></span>.
68    </p>
69      <p>
70         Because databases opened within Berkeley DB environments use the cache
71         specified to the environment, it is an error to attempt to set a cache
72         in a database created within an environment.
73    </p>
74      <p>
75             The <code class="methodname">DB-&gt;set_cachesize()</code> method may not be called after the 
76             <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a>  method is called.
77    </p>
78      <p>
79         The <code class="methodname">DB-&gt;set_cachesize()</code> <span>
80            <span>
81                  method returns a non-zero error value on failure and 0 on success.
82            </span>
83            
84        </span>
85    </p>
86      <div class="sect2" lang="en" xml:lang="en">
87        <div class="titlepage">
88          <div>
89            <div>
90              <h3 class="title"><a id="id1644406"></a>Parameters</h3>
91            </div>
92          </div>
93        </div>
94        <div class="sect3" lang="en" xml:lang="en">
95          <div class="titlepage">
96            <div>
97              <div>
98                <h4 class="title"><a id="id1644378"></a>bytes</h4>
99              </div>
100            </div>
101          </div>
102          <p>
103                          The size of the cache is set to <span class="bold"><strong>gbytes</strong></span> gigabytes plus <span class="bold"><strong>bytes</strong></span>.
104                     </p>
105        </div>
106        <div class="sect3" lang="en" xml:lang="en">
107          <div class="titlepage">
108            <div>
109              <div>
110                <h4 class="title"><a id="id1644629"></a>gbytes</h4>
111              </div>
112            </div>
113          </div>
114          <p>
115                          The size of the cache is set to <span class="bold"><strong>gbytes</strong></span> gigabytes plus <span class="bold"><strong>bytes</strong></span>.
116                     </p>
117        </div>
118        <div class="sect3" lang="en" xml:lang="en">
119          <div class="titlepage">
120            <div>
121              <div>
122                <h4 class="title"><a id="id1644721"></a>ncache</h4>
123              </div>
124            </div>
125          </div>
126          <p>
127                          The <span class="bold"><strong>ncache</strong></span> parameter is the number of
128                          caches to create.
129                     </p>
130        </div>
131      </div>
132      <div class="sect2" lang="en" xml:lang="en">
133        <div class="titlepage">
134          <div>
135            <div>
136              <h3 class="title"><a id="id1644740"></a>Errors</h3>
137            </div>
138          </div>
139        </div>
140        <p>
141                         The <code class="methodname">DB-&gt;set_cachesize()</code> <span>
142            <span>
143                 method may fail and return one of the following non-zero errors:
144            </span>
145            
146        </span>
147                    </p>
148        <div class="sect3" lang="en" xml:lang="en">
149          <div class="titlepage">
150            <div>
151              <div>
152                <h4 class="title"><a id="id1644696"></a>EINVAL</h4>
153              </div>
154            </div>
155          </div>
156          <p>
157                              If the specified cache size was impossibly small; the method was
158                              called after <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a> 
159                              was called; or if an invalid flag value or parameter was specified.
160                         </p>
161        </div>
162      </div>
163      <div class="sect2" lang="en" xml:lang="en">
164        <div class="titlepage">
165          <div>
166            <div>
167              <h3 class="title"><a id="id1644779"></a>Class</h3>
168            </div>
169          </div>
170        </div>
171        <p>
172                <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a>  
173            </p>
174      </div>
175      <div class="sect2" lang="en" xml:lang="en">
176        <div class="titlepage">
177          <div>
178            <div>
179              <h3 class="title"><a id="id1644485"></a>See Also</h3>
180            </div>
181          </div>
182        </div>
183        <p>
184                     <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 
185                </p>
186      </div>
187    </div>
188    <div class="navfooter">
189      <hr />
190      <table width="100%" summary="Navigation footer">
191        <tr>
192          <td width="40%" align="left"><a accesskey="p" href="dbset_bt_prefix.html">Prev</a>��</td>
193          <td width="20%" align="center">
194            <a accesskey="u" href="db.html">Up</a>
195          </td>
196          <td width="40%" align="right">��<a accesskey="n" href="dbset_create_dir.html">Next</a></td>
197        </tr>
198        <tr>
199          <td width="40%" align="left" valign="top">DB-&gt;set_bt_prefix()��</td>
200          <td width="20%" align="center">
201            <a accesskey="h" href="index.html">Home</a>
202          </td>
203          <td width="40%" align="right" valign="top">��DB-&gt;set_create_dir()</td>
204        </tr>
205      </table>
206    </div>
207  </body>
208</html>
209