• 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_ENV-&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="memp.html" title="Chapter��8.�� The DB_MPOOLFILE Handle" />
11    <link rel="prev" href="envset_cache_max.html" title="DB_ENV-&gt;set_cache_max()" />
12    <link rel="next" href="mempset_mp_max_openfd.html" title="DB_ENV-&gt;set_mp_max_openfd()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">DB_ENV-&gt;set_cachesize()</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="envset_cache_max.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��8.��
23              The  DB_MPOOLFILE Handle
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="mempset_mp_max_openfd.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="envset_cachesize"></a>DB_ENV-&gt;set_cachesize()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db.h&gt;
39
40int
41DB_ENV-&gt;set_cachesize(DB_ENV *dbenv,
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 cache 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         The cache may be resized by calling <code class="methodname">DB_ENV-&gt;set_cachesize()</code>
71         after the environment is open.  The supplied size will be rounded to the nearest multiple
72         of the region size and may not be larger than the maximum size configured with 
73         <a class="xref" href="envset_cache_max.html" title="DB_ENV-&gt;set_cache_max()">DB_ENV-&gt;set_cache_max()</a>.  The 
74         <span class="bold"><strong>ncache</strong></span> parameter is ignored when resizing the cache.
75
76    </p>
77      <p>
78         The database environment's initial cache size may also be configured
79         using the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file.  The
80         syntax of the entry in that file is a single line with the string
81         "set_cachesize", one or more whitespace characters, and the initial
82         cache size specified in three parts: the gigabytes of cache, the
83         additional bytes of cache, and the number of caches, also separated by
84         whitespace characters.  For example, "set_cachesize 2 524288000 3"
85         would create a 2.5GB logical cache, split between three physical
86         caches. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is
87         read when the database environment is opened, it will silently
88         overrule configuration done before that time.
89    </p>
90      <p>
91         The <code class="methodname">DB_ENV-&gt;set_cachesize()</code> method configures a database environment,
92         not only operations performed using the specified <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a>  handle.
93    </p>
94      <p>
95         The <code class="methodname">DB_ENV-&gt;set_cachesize()</code> method may be called at any time during
96         the life of the application.
97    </p>
98      <p>
99         The <code class="methodname">DB_ENV-&gt;set_cachesize()</code> <span>
100            <span>
101                  method returns a non-zero error value on failure and 0 on success.
102            </span>
103            
104        </span>
105    </p>
106      <div class="sect2" lang="en" xml:lang="en">
107        <div class="titlepage">
108          <div>
109            <div>
110              <h3 class="title"><a id="id1688516"></a>Parameters</h3>
111            </div>
112          </div>
113        </div>
114        <div class="sect3" lang="en" xml:lang="en">
115          <div class="titlepage">
116            <div>
117              <div>
118                <h4 class="title"><a id="id1688522"></a>bytes</h4>
119              </div>
120            </div>
121          </div>
122          <p>
123                          The size of the cache is set to <span class="bold"><strong>gbytes</strong></span> gigabytes plus <span class="bold"><strong>bytes</strong></span>.
124                     </p>
125        </div>
126        <div class="sect3" lang="en" xml:lang="en">
127          <div class="titlepage">
128            <div>
129              <div>
130                <h4 class="title"><a id="id1688666"></a>gbytes</h4>
131              </div>
132            </div>
133          </div>
134          <p>
135                          The size of the cache is set to <span class="bold"><strong>gbytes</strong></span> gigabytes plus <span class="bold"><strong>bytes</strong></span>.
136                     </p>
137        </div>
138        <div class="sect3" lang="en" xml:lang="en">
139          <div class="titlepage">
140            <div>
141              <div>
142                <h4 class="title"><a id="id1688254"></a>ncache</h4>
143              </div>
144            </div>
145          </div>
146          <p>
147                          The <span class="bold"><strong>ncache</strong></span> parameter is the number of
148                          caches to create.
149                     </p>
150        </div>
151      </div>
152      <div class="sect2" lang="en" xml:lang="en">
153        <div class="titlepage">
154          <div>
155            <div>
156              <h3 class="title"><a id="id1688706"></a>Errors</h3>
157            </div>
158          </div>
159        </div>
160        <p>
161                         The <code class="methodname">DB_ENV-&gt;set_cachesize()</code> <span>
162            <span>
163                 method may fail and return one of the following non-zero errors:
164            </span>
165            
166        </span>
167                    </p>
168        <div class="sect3" lang="en" xml:lang="en">
169          <div class="titlepage">
170            <div>
171              <div>
172                <h4 class="title"><a id="id1688657"></a>EINVAL</h4>
173              </div>
174            </div>
175          </div>
176          <p>
177                              If the specified cache size was impossibly small; or if an invalid
178                              flag value or parameter was specified.
179                         </p>
180        </div>
181      </div>
182      <div class="sect2" lang="en" xml:lang="en">
183        <div class="titlepage">
184          <div>
185            <div>
186              <h3 class="title"><a id="id1688658"></a>Class</h3>
187            </div>
188          </div>
189        </div>
190        <p>
191                    <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a>  
192            </p>
193      </div>
194      <div class="sect2" lang="en" xml:lang="en">
195        <div class="titlepage">
196          <div>
197            <div>
198              <h3 class="title"><a id="id1688530"></a>See Also</h3>
199            </div>
200          </div>
201        </div>
202        <p>
203                     <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 
204                </p>
205      </div>
206    </div>
207    <div class="navfooter">
208      <hr />
209      <table width="100%" summary="Navigation footer">
210        <tr>
211          <td width="40%" align="left"><a accesskey="p" href="envset_cache_max.html">Prev</a>��</td>
212          <td width="20%" align="center">
213            <a accesskey="u" href="memp.html">Up</a>
214          </td>
215          <td width="40%" align="right">��<a accesskey="n" href="mempset_mp_max_openfd.html">Next</a></td>
216        </tr>
217        <tr>
218          <td width="40%" align="left" valign="top">DB_ENV-&gt;set_cache_max()��</td>
219          <td width="20%" align="center">
220            <a accesskey="h" href="index.html">Home</a>
221          </td>
222          <td width="40%" align="right" valign="top">��DB_ENV-&gt;set_mp_max_openfd()</td>
223        </tr>
224      </table>
225    </div>
226  </body>
227</html>
228