proxy.html
来自「perl教程」· HTML 代码 · 共 329 行 · 第 1/2 页
HTML
329 行
<p>and pass this object to the RPC::PlClient module when creating a
client. See <a href="../../RPC/PlClient.html">the RPC::PlClient manpage</a>. Example:</p>
</dd>
<dd>
<pre>
<span class="variable">cipher</span><span class="operator">=</span><span class="variable">IDEA</span><span class="operator">;</span><span class="variable">key</span><span class="operator">=</span><span class="number">97</span><span class="variable">cd2375efa329aceef2098babdc9721</span>
</pre>
</dd>
<dd>
<p>The usercipher/userkey attributes allow you to use two phase encryption:
The cipher/key encryption will be used in the login and authorisation
phase. Once the client is authorised, he will change to usercipher/userkey
encryption. Thus the cipher/key pair is a <strong>host</strong> based secret, typically
less secure than the usercipher/userkey secret and readable by anyone.
The usercipher/userkey secret is <strong>your</strong> private secret.</p>
</dd>
<dd>
<p>Of course encryption requires an appropriately configured server. See
<DBD::ProxyServer/CONFIGURATION FILE>.</p>
</dd>
</li>
<dt><strong><a name="item_debug">debug</a></strong>
<dd>
<p>Turn on debugging mode</p>
</dd>
</li>
<dt><strong><a name="item_stderr">stderr</a></strong>
<dd>
<p>This attribute will set the corresponding attribute of the RPC::PlClient
object, thus logging will not use syslog(), but redirected to stderr.
This is the default under Windows.</p>
</dd>
<dd>
<pre>
stderr=1</pre>
</dd>
</li>
<dt><strong><a name="item_logfile">logfile</a></strong>
<dd>
<p>Similar to the stderr attribute, but output will be redirected to the
given file.</p>
</dd>
<dd>
<pre>
logfile=/dev/null</pre>
</dd>
</li>
<dt><strong><a name="item_rowcachesize">RowCacheSize</a></strong>
<dd>
<p>The DBD::Proxy driver supports this attribute (which is DBI standard,
as of DBI 1.02). It's used to reduce network round-trips by fetching
multiple rows in one go. The current default value is 20, but this may
change.</p>
</dd>
</li>
<dt><strong><a name="item_proxy_no_finish">proxy_no_finish</a></strong>
<dd>
<p>This attribute can be used to reduce network traffic: If the
application is calling $sth-><code>finish()</code> then the proxy tells the server
to finish the remote statement handle. Of course this slows down things
quite a lot, but is prefectly good for reducing memory usage with
persistent connections.</p>
</dd>
<dd>
<p>However, if you set the <em>proxy_no_finish</em> attribute to a TRUE value,
either in the database handle or in the statement handle, then <code>finish()</code>
calls will be supressed. This is what you want, for example, in small
and fast CGI applications.</p>
</dd>
</li>
<dt><strong><a name="item_proxy_quote">proxy_quote</a></strong>
<dd>
<p>This attribute can be used to reduce network traffic: By default calls
to $dbh-><code>quote()</code> are passed to the remote driver. Of course this slows
down things quite a lot, but is the safest default behaviour.</p>
</dd>
<dd>
<p>However, if you set the <em>proxy_quote</em> attribute to the value '<a href="../../lib/Pod/perlfunc.html#item_local"><code>local</code></a>'
either in the database handle or in the statement handle, and the call
to quote has only one parameter, then the local default DBI quote
method will be used (which will be faster but may be wrong).</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="known_issues">KNOWN ISSUES</a></h1>
<p>
</p>
<h2><a name="complex_handle_attributes">Complex handle attributes</a></h2>
<p>Sometimes handles are having complex attributes like hash refs or
array refs and not simple strings or integers. For example, with
DBD::CSV, you would like to write something like</p>
<pre>
<span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">"csv_tables"</span><span class="operator">}</span><span class="operator">-></span><span class="operator">{</span><span class="string">"passwd"</span><span class="operator">}</span> <span class="operator">=</span>
<span class="operator">{</span> <span class="string">"sep_char"</span> <span class="operator">=></span> <span class="string">":"</span><span class="operator">,</span> <span class="string">"eol"</span> <span class="operator">=></span> <span class="string">"\n"</span><span class="operator">;</span>
</pre>
<p>The above example would advice the CSV driver to assume the file
"passwd" to be in the format of the /etc/passwd file: Colons as
separators and a line feed without carriage return as line
terminator.</p>
<p>Surprisingly this example doesn't work with the proxy driver. To understand
the reasons, you should consider the following: The Perl compiler is
executing the above example in two steps:</p>
<ol>
<li>
<p>The first step is fetching the value of the key "csv_tables" in the
handle $dbh. The value returned is complex, a hash ref.</p>
</li>
<li>
<p>The second step is storing some value (the right hand side of the
assignment) as the key "passwd" in the hash ref from step 1.</p>
</li>
</ol>
<p>This becomes a little bit clearer, if we rewrite the above code:</p>
<pre>
<span class="variable">$tables</span> <span class="operator">=</span> <span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">"csv_tables"</span><span class="operator">}</span><span class="operator">;</span>
<span class="variable">$tables</span><span class="operator">-></span><span class="operator">{</span><span class="string">"passwd"</span><span class="operator">}</span> <span class="operator">=</span> <span class="operator">{</span> <span class="string">"sep_char"</span> <span class="operator">=></span> <span class="string">":"</span><span class="operator">,</span> <span class="string">"eol"</span> <span class="operator">=></span> <span class="string">"\n"</span><span class="operator">;</span>
</pre>
<p>While the examples work fine without the proxy, the fail due to a
subtile difference in step 1: By DBI magic, the hash ref
$dbh->{'csv_tables'} is returned from the server to the client.
The client creates a local copy. This local copy is the result of
step 1. In other words, step 2 modifies a local copy of the hash ref,
but not the server's hash ref.</p>
<p>The workaround is storing the modified local copy back to the server:</p>
<pre>
<span class="variable">$tables</span> <span class="operator">=</span> <span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">"csv_tables"</span><span class="operator">}</span><span class="operator">;</span>
<span class="variable">$tables</span><span class="operator">-></span><span class="operator">{</span><span class="string">"passwd"</span><span class="operator">}</span> <span class="operator">=</span> <span class="operator">{</span> <span class="string">"sep_char"</span> <span class="operator">=></span> <span class="string">":"</span><span class="operator">,</span> <span class="string">"eol"</span> <span class="operator">=></span> <span class="string">"\n"</span><span class="operator">;</span>
<span class="variable">$dbh</span><span class="operator">-></span><span class="operator">{</span><span class="string">"csv_tables"</span><span class="operator">}</span> <span class="operator">=</span> <span class="variable">$tables</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="author_and_copyright">AUTHOR AND COPYRIGHT</a></h1>
<p>This module is Copyright (c) 1997, 1998</p>
<pre>
Jochen Wiedmann
Am Eisteich 9
72555 Metzingen
Germany</pre>
<pre>
Email: joe@ispsoft.de
Phone: +49 7123 14887</pre>
<p>The DBD::Proxy module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. In particular permission
is granted to Tim Bunce for distributing this as a part of the DBI.</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/DBI.html">the DBI manpage</a>, <a href="../../RPC/PlClient.html">the RPC::PlClient manpage</a>, <a href="../../lib/Storable.html">the Storable manpage</a></p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?