/usr/share/doc/python-requests-cache-doc/html/api.html is in python-requests-cache-doc 0.4.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>API — requests-cache 0.4.10 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.4.10',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="requests-cache 0.4.10 documentation" href="index.html" />
<link rel="prev" title="User guide" href="user_guide.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="user_guide.html" title="User guide"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">requests-cache 0.4.10 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="api">
<h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
<p>This part of the documentation covers all the interfaces of <cite>requests-cache</cite></p>
<div class="section" id="module-requests_cache.core">
<span id="public-api"></span><h2>Public api<a class="headerlink" href="#module-requests_cache.core" title="Permalink to this headline">¶</a></h2>
<div class="section" id="requests-cache-core">
<h3>requests_cache.core<a class="headerlink" href="#requests-cache-core" title="Permalink to this headline">¶</a></h3>
<p>Core functions for configuring cache and monkey patching <code class="docutils literal"><span class="pre">requests</span></code></p>
<dl class="class">
<dt id="requests_cache.core.CachedSession">
<em class="property">class </em><code class="descclassname">requests_cache.core.</code><code class="descname">CachedSession</code><span class="sig-paren">(</span><em>cache_name='cache'</em>, <em>backend=None</em>, <em>expire_after=None</em>, <em>allowable_codes=(200</em>, <em>)</em>, <em>allowable_methods=('GET'</em>, <em>)</em>, <em>old_data_on_error=False</em>, <em>**backend_options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.CachedSession" title="Permalink to this definition">¶</a></dt>
<dd><p>Requests <code class="docutils literal"><span class="pre">Sessions</span></code> with caching support.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>cache_name</strong> – <p>for <code class="docutils literal"><span class="pre">sqlite</span></code> backend: cache file will start with this prefix,
e.g <code class="docutils literal"><span class="pre">cache.sqlite</span></code></p>
<p>for <code class="docutils literal"><span class="pre">mongodb</span></code>: it’s used as database name</p>
<p>for <code class="docutils literal"><span class="pre">redis</span></code>: it’s used as the namespace. This means all keys
are prefixed with <code class="docutils literal"><span class="pre">'cache_name:'</span></code></p>
</li>
<li><strong>backend</strong> – cache backend name e.g <code class="docutils literal"><span class="pre">'sqlite'</span></code>, <code class="docutils literal"><span class="pre">'mongodb'</span></code>, <code class="docutils literal"><span class="pre">'redis'</span></code>, <code class="docutils literal"><span class="pre">'memory'</span></code>.
(see <a class="reference internal" href="user_guide.html#persistence"><span>Persistence</span></a>). Or instance of backend implementation.
Default value is <code class="docutils literal"><span class="pre">None</span></code>, which means use <code class="docutils literal"><span class="pre">'sqlite'</span></code> if available,
otherwise fallback to <code class="docutils literal"><span class="pre">'memory'</span></code>.</li>
<li><strong>expire_after</strong> (<em>float</em>) – <code class="docutils literal"><span class="pre">timedelta</span></code> or number of seconds after cache will be expired
or <cite>None</cite> (default) to ignore expiration</li>
<li><strong>allowable_codes</strong> (<em>tuple</em>) – limit caching only for response with this codes (default: 200)</li>
<li><strong>allowable_methods</strong> (<em>tuple</em>) – cache only requests of this methods (default: ‘GET’)</li>
<li><strong>backend_options</strong> – options for chosen backend. See corresponding
<a class="reference internal" href="#backends-sqlite"><span>sqlite</span></a>, <a class="reference internal" href="#backends-mongo"><span>mongo</span></a>
and <a class="reference internal" href="#backends-redis"><span>redis</span></a> backends API documentation</li>
<li><strong>include_get_headers</strong> – If <cite>True</cite> headers will be part of cache key.
E.g. after get(‘some_link’, headers={‘Accept’:’application/json’})
get(‘some_link’, headers={‘Accept’:’application/xml’}) is not from cache.</li>
<li><strong>old_data_on_error</strong> – If <cite>True</cite> it will return expired cached response if update fails</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="requests_cache.core.CachedSession.cache_disabled">
<code class="descname">cache_disabled</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwds</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.CachedSession.cache_disabled" title="Permalink to this definition">¶</a></dt>
<dd><p>Context manager for temporary disabling cache</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">s</span> <span class="o">=</span> <span class="n">CachedSession</span><span class="p">()</span>
<span class="gp">>>> </span><span class="k">with</span> <span class="n">s</span><span class="o">.</span><span class="n">cache_disabled</span><span class="p">():</span>
<span class="gp">... </span> <span class="n">s</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/ip'</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.install_cache">
<code class="descclassname">requests_cache.core.</code><code class="descname">install_cache</code><span class="sig-paren">(</span><em>cache_name='cache'</em>, <em>backend=None</em>, <em>expire_after=None</em>, <em>allowable_codes=(200</em>, <em>)</em>, <em>allowable_methods=('GET'</em>, <em>)</em>, <em>session_factory=<class 'requests_cache.core.CachedSession'></em>, <em>**backend_options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.install_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Installs cache for all <code class="docutils literal"><span class="pre">Requests</span></code> requests by monkey-patching <code class="docutils literal"><span class="pre">Session</span></code></p>
<p>Parameters are the same as in <a class="reference internal" href="#requests_cache.core.CachedSession" title="requests_cache.core.CachedSession"><code class="xref py py-class docutils literal"><span class="pre">CachedSession</span></code></a>. Additional parameters:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>session_factory</strong> – Session factory. It must be class which inherits <a class="reference internal" href="#requests_cache.core.CachedSession" title="requests_cache.core.CachedSession"><code class="xref py py-class docutils literal"><span class="pre">CachedSession</span></code></a> (default)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.configure">
<code class="descclassname">requests_cache.core.</code><code class="descname">configure</code><span class="sig-paren">(</span><em>cache_name='cache'</em>, <em>backend=None</em>, <em>expire_after=None</em>, <em>allowable_codes=(200</em>, <em>)</em>, <em>allowable_methods=('GET'</em>, <em>)</em>, <em>session_factory=<class 'requests_cache.core.CachedSession'></em>, <em>**backend_options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.configure" title="Permalink to this definition">¶</a></dt>
<dd><p>Installs cache for all <code class="docutils literal"><span class="pre">Requests</span></code> requests by monkey-patching <code class="docutils literal"><span class="pre">Session</span></code></p>
<p>Parameters are the same as in <a class="reference internal" href="#requests_cache.core.CachedSession" title="requests_cache.core.CachedSession"><code class="xref py py-class docutils literal"><span class="pre">CachedSession</span></code></a>. Additional parameters:</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>session_factory</strong> – Session factory. It must be class which inherits <a class="reference internal" href="#requests_cache.core.CachedSession" title="requests_cache.core.CachedSession"><code class="xref py py-class docutils literal"><span class="pre">CachedSession</span></code></a> (default)</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.uninstall_cache">
<code class="descclassname">requests_cache.core.</code><code class="descname">uninstall_cache</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.uninstall_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Restores <code class="docutils literal"><span class="pre">requests.Session</span></code> and disables cache</p>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.disabled">
<code class="descclassname">requests_cache.core.</code><code class="descname">disabled</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwds</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.disabled" title="Permalink to this definition">¶</a></dt>
<dd><p>Context manager for temporary disabling globally installed cache</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">not thread-safe</p>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">with</span> <span class="n">requests_cache</span><span class="o">.</span><span class="n">disabled</span><span class="p">():</span>
<span class="gp">... </span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/ip'</span><span class="p">)</span>
<span class="gp">... </span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.enabled">
<code class="descclassname">requests_cache.core.</code><code class="descname">enabled</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwds</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.enabled" title="Permalink to this definition">¶</a></dt>
<dd><p>Context manager for temporary installing global cache.</p>
<p>Accepts same arguments as <a class="reference internal" href="#requests_cache.core.install_cache" title="requests_cache.core.install_cache"><code class="xref py py-func docutils literal"><span class="pre">install_cache()</span></code></a></p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">not thread-safe</p>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">with</span> <span class="n">requests_cache</span><span class="o">.</span><span class="n">enabled</span><span class="p">(</span><span class="s">'cache_db'</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">'http://httpbin.org/get'</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.get_cache">
<code class="descclassname">requests_cache.core.</code><code class="descname">get_cache</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.get_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns internal cache object from globally installed <code class="docutils literal"><span class="pre">CachedSession</span></code></p>
</dd></dl>
<dl class="function">
<dt id="requests_cache.core.clear">
<code class="descclassname">requests_cache.core.</code><code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.core.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clears globally installed cache</p>
</dd></dl>
</div>
<hr class="docutils" />
</div>
<div class="section" id="module-requests_cache.backends.base">
<span id="id1"></span><span id="cache-backends"></span><h2>Cache backends<a class="headerlink" href="#module-requests_cache.backends.base" title="Permalink to this headline">¶</a></h2>
<div class="section" id="requests-cache-backends-base">
<h3>requests_cache.backends.base<a class="headerlink" href="#requests-cache-backends-base" title="Permalink to this headline">¶</a></h3>
<p>Contains BaseCache class which can be used as in-memory cache backend or
extended to support persistence.</p>
<dl class="class">
<dt id="requests_cache.backends.base.BaseCache">
<em class="property">class </em><code class="descclassname">requests_cache.backends.base.</code><code class="descname">BaseCache</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class for cache implementations, can be used as in-memory cache.</p>
<p>To extend it you can provide dictionary-like objects for
<a class="reference internal" href="#requests_cache.backends.base.BaseCache.keys_map" title="requests_cache.backends.base.BaseCache.keys_map"><code class="xref py py-attr docutils literal"><span class="pre">keys_map</span></code></a> and <a class="reference internal" href="#requests_cache.backends.base.BaseCache.responses" title="requests_cache.backends.base.BaseCache.responses"><code class="xref py py-attr docutils literal"><span class="pre">responses</span></code></a> or override public methods.</p>
<dl class="attribute">
<dt id="requests_cache.backends.base.BaseCache.keys_map">
<code class="descname">keys_map</code><em class="property"> = None</em><a class="headerlink" href="#requests_cache.backends.base.BaseCache.keys_map" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>key</cite> -> <cite>key_in_responses</cite> mapping</p>
</dd></dl>
<dl class="attribute">
<dt id="requests_cache.backends.base.BaseCache.responses">
<code class="descname">responses</code><em class="property"> = None</em><a class="headerlink" href="#requests_cache.backends.base.BaseCache.responses" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>key_in_cache</cite> -> <cite>response</cite> mapping</p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.save_response">
<code class="descname">save_response</code><span class="sig-paren">(</span><em>key</em>, <em>response</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.save_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Save response to cache</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – key for this response</li>
<li><strong>response</strong> – response to save</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Response is reduced before saving (with <a class="reference internal" href="#requests_cache.backends.base.BaseCache.reduce_response" title="requests_cache.backends.base.BaseCache.reduce_response"><code class="xref py py-meth docutils literal"><span class="pre">reduce_response()</span></code></a>)
to make it picklable</p>
</div>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.add_key_mapping">
<code class="descname">add_key_mapping</code><span class="sig-paren">(</span><em>new_key</em>, <em>key_to_response</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.add_key_mapping" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds mapping of <cite>new_key</cite> to <cite>key_to_response</cite> to make it possible to
associate many keys with single response</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>new_key</strong> – new key (e.g. url from redirect)</li>
<li><strong>key_to_response</strong> – key which can be found in <a class="reference internal" href="#requests_cache.backends.base.BaseCache.responses" title="requests_cache.backends.base.BaseCache.responses"><code class="xref py py-attr docutils literal"><span class="pre">responses</span></code></a></li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.get_response_and_time">
<code class="descname">get_response_and_time</code><span class="sig-paren">(</span><em>key</em>, <em>default=(None</em>, <em>None)</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.get_response_and_time" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieves response and timestamp for <cite>key</cite> if it’s stored in cache,
otherwise returns <cite>default</cite></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>key</strong> – key of resource</li>
<li><strong>default</strong> – return this if <cite>key</cite> not found in cache</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple (response, datetime)</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Response is restored after unpickling with <a class="reference internal" href="#requests_cache.backends.base.BaseCache.restore_response" title="requests_cache.backends.base.BaseCache.restore_response"><code class="xref py py-meth docutils literal"><span class="pre">restore_response()</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.delete">
<code class="descname">delete</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete <cite>key</cite> from cache. Also deletes all responses from response history</p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.delete_url">
<code class="descname">delete_url</code><span class="sig-paren">(</span><em>url</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.delete_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete response associated with <cite>url</cite> from cache.
Also deletes all responses from response history. Works only for GET requests</p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear cache</p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.has_key">
<code class="descname">has_key</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.has_key" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <cite>True</cite> if cache has <cite>key</cite>, <cite>False</cite> otherwise</p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.has_url">
<code class="descname">has_url</code><span class="sig-paren">(</span><em>url</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.has_url" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <cite>True</cite> if cache has <cite>url</cite>, <cite>False</cite> otherwise.
Works only for GET request urls</p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.reduce_response">
<code class="descname">reduce_response</code><span class="sig-paren">(</span><em>response</em>, <em>seen=None</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.reduce_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduce response object to make it compatible with <code class="docutils literal"><span class="pre">pickle</span></code></p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.base.BaseCache.restore_response">
<code class="descname">restore_response</code><span class="sig-paren">(</span><em>response</em>, <em>seen=None</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.base.BaseCache.restore_response" title="Permalink to this definition">¶</a></dt>
<dd><p>Restore response object after unpickling</p>
</dd></dl>
</dd></dl>
</div>
<span class="target" id="module-requests_cache.backends.sqlite"><span id="backends-sqlite"></span></span><div class="section" id="requests-cache-backends-sqlite">
<h3>requests_cache.backends.sqlite<a class="headerlink" href="#requests-cache-backends-sqlite" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">sqlite3</span></code> cache backend</p>
<dl class="class">
<dt id="requests_cache.backends.sqlite.DbCache">
<em class="property">class </em><code class="descclassname">requests_cache.backends.sqlite.</code><code class="descname">DbCache</code><span class="sig-paren">(</span><em>location='cache'</em>, <em>fast_save=False</em>, <em>extension='.sqlite'</em>, <em>**options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.sqlite.DbCache" title="Permalink to this definition">¶</a></dt>
<dd><p>sqlite cache backend.</p>
<p>Reading is fast, saving is a bit slower. It can store big amount of data
with low memory usage.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>location</strong> – database filename prefix (default: <code class="docutils literal"><span class="pre">'cache'</span></code>)</li>
<li><strong>fast_save</strong> – Speedup cache saving up to 50 times but with possibility of data loss.
See <a class="reference internal" href="#backends-dbdict"><span>backends.DbDict</span></a> for more info</li>
<li><strong>extension</strong> – extension for filename (default: <code class="docutils literal"><span class="pre">'.sqlite'</span></code>)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<span class="target" id="module-requests_cache.backends.mongo"><span id="backends-mongo"></span></span><div class="section" id="requests-cache-backends-mongo">
<h3>requests_cache.backends.mongo<a class="headerlink" href="#requests-cache-backends-mongo" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">mongo</span></code> cache backend</p>
<dl class="class">
<dt id="requests_cache.backends.mongo.MongoCache">
<em class="property">class </em><code class="descclassname">requests_cache.backends.mongo.</code><code class="descname">MongoCache</code><span class="sig-paren">(</span><em>db_name='requests-cache'</em>, <em>**options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.mongo.MongoCache" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal"><span class="pre">mongo</span></code> cache backend.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>db_name</strong> – database name (default: <code class="docutils literal"><span class="pre">'requests-cache'</span></code>)</li>
<li><strong>connection</strong> – (optional) <code class="docutils literal"><span class="pre">pymongo.Connection</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<span class="target" id="module-requests_cache.backends.redis"><span id="backends-redis"></span></span><div class="section" id="requests-cache-backends-redis">
<h3>requests_cache.backends.redis<a class="headerlink" href="#requests-cache-backends-redis" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">redis</span></code> cache backend</p>
<dl class="class">
<dt id="requests_cache.backends.redis.RedisCache">
<em class="property">class </em><code class="descclassname">requests_cache.backends.redis.</code><code class="descname">RedisCache</code><span class="sig-paren">(</span><em>namespace='requests-cache'</em>, <em>**options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.redis.RedisCache" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal"><span class="pre">redis</span></code> cache backend.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>namespace</strong> – redis namespace (default: <code class="docutils literal"><span class="pre">'requests-cache'</span></code>)</li>
<li><strong>connection</strong> – (optional) <code class="docutils literal"><span class="pre">redis.StrictRedis</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
</div>
<hr class="docutils" />
<div class="section" id="internal-modules-which-can-be-used-outside">
<h2>Internal modules which can be used outside<a class="headerlink" href="#internal-modules-which-can-be-used-outside" title="Permalink to this headline">¶</a></h2>
<span class="target" id="module-requests_cache.backends.storage.dbdict"><span id="backends-dbdict"></span></span><div class="section" id="requests-cache-backends-dbdict">
<h3>requests_cache.backends.dbdict<a class="headerlink" href="#requests-cache-backends-dbdict" title="Permalink to this headline">¶</a></h3>
<p>Dictionary-like objects for saving large data sets to <cite>sqlite</cite> database</p>
<dl class="class">
<dt id="requests_cache.backends.storage.dbdict.DbDict">
<em class="property">class </em><code class="descclassname">requests_cache.backends.storage.dbdict.</code><code class="descname">DbDict</code><span class="sig-paren">(</span><em>filename</em>, <em>table_name='data'</em>, <em>fast_save=False</em>, <em>**options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.dbdict.DbDict" title="Permalink to this definition">¶</a></dt>
<dd><p>DbDict - a dictionary-like object for saving large datasets to <cite>sqlite</cite> database</p>
<p>It’s possible to create multiply DbDict instances, which will be stored as separate
tables in one database:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">d1</span> <span class="o">=</span> <span class="n">DbDict</span><span class="p">(</span><span class="s">'test'</span><span class="p">,</span> <span class="s">'table1'</span><span class="p">)</span>
<span class="n">d2</span> <span class="o">=</span> <span class="n">DbDict</span><span class="p">(</span><span class="s">'test'</span><span class="p">,</span> <span class="s">'table2'</span><span class="p">)</span>
<span class="n">d3</span> <span class="o">=</span> <span class="n">DbDict</span><span class="p">(</span><span class="s">'test'</span><span class="p">,</span> <span class="s">'table3'</span><span class="p">)</span>
</pre></div>
</div>
<p>all data will be stored in <code class="docutils literal"><span class="pre">test.sqlite</span></code> database into
correspondent tables: <code class="docutils literal"><span class="pre">table1</span></code>, <code class="docutils literal"><span class="pre">table2</span></code> and <code class="docutils literal"><span class="pre">table3</span></code></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> – filename for database (without extension)</li>
<li><strong>table_name</strong> – table name</li>
<li><strong>fast_save</strong> – If it’s True, then sqlite will be configured with
<a class="reference external" href="http://www.sqlite.org/pragma.html#pragma_synchronous">“PRAGMA synchronous = 0;”</a>
to speedup cache saving, but be careful, it’s dangerous.
Tests showed that insertion order of records can be wrong with this option.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="requests_cache.backends.storage.dbdict.DbDict.can_commit">
<code class="descname">can_commit</code><em class="property"> = None</em><a class="headerlink" href="#requests_cache.backends.storage.dbdict.DbDict.can_commit" title="Permalink to this definition">¶</a></dt>
<dd><p>Transactions can be commited if this property is set to <cite>True</cite></p>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.storage.dbdict.DbDict.commit">
<code class="descname">commit</code><span class="sig-paren">(</span><em>force=False</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.dbdict.DbDict.commit" title="Permalink to this definition">¶</a></dt>
<dd><p>Commits pending transaction if <a class="reference internal" href="#requests_cache.backends.storage.dbdict.DbDict.can_commit" title="requests_cache.backends.storage.dbdict.DbDict.can_commit"><code class="xref py py-attr docutils literal"><span class="pre">can_commit</span></code></a> or <cite>force</cite> is <cite>True</cite></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>force</strong> – force commit, ignore <a class="reference internal" href="#requests_cache.backends.storage.dbdict.DbDict.can_commit" title="requests_cache.backends.storage.dbdict.DbDict.can_commit"><code class="xref py py-attr docutils literal"><span class="pre">can_commit</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="requests_cache.backends.storage.dbdict.DbDict.bulk_commit">
<code class="descname">bulk_commit</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwds</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.dbdict.DbDict.bulk_commit" title="Permalink to this definition">¶</a></dt>
<dd><p>Context manager used to speedup insertion of big number of records</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">d1</span> <span class="o">=</span> <span class="n">DbDict</span><span class="p">(</span><span class="s">'test'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">with</span> <span class="n">d1</span><span class="o">.</span><span class="n">bulk_commit</span><span class="p">():</span>
<span class="gp">... </span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">d1</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">i</span> <span class="o">*</span> <span class="mi">2</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="requests_cache.backends.storage.dbdict.DbPickleDict">
<em class="property">class </em><code class="descclassname">requests_cache.backends.storage.dbdict.</code><code class="descname">DbPickleDict</code><span class="sig-paren">(</span><em>filename</em>, <em>table_name='data'</em>, <em>fast_save=False</em>, <em>**options</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.dbdict.DbPickleDict" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#requests_cache.backends.storage.dbdict.DbDict" title="requests_cache.backends.storage.dbdict.DbDict"><code class="xref py py-class docutils literal"><span class="pre">DbDict</span></code></a>, but pickles values before saving</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>filename</strong> – filename for database (without extension)</li>
<li><strong>table_name</strong> – table name</li>
<li><strong>fast_save</strong> – <p>If it’s True, then sqlite will be configured with
<a class="reference external" href="http://www.sqlite.org/pragma.html#pragma_synchronous">“PRAGMA synchronous = 0;”</a>
to speedup cache saving, but be careful, it’s dangerous.
Tests showed that insertion order of records can be wrong with this option.</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<span class="target" id="module-requests_cache.backends.storage.mongodict"></span><div class="section" id="requests-cache-backends-mongodict">
<h3>requests_cache.backends.mongodict<a class="headerlink" href="#requests-cache-backends-mongodict" title="Permalink to this headline">¶</a></h3>
<p>Dictionary-like objects for saving large data sets to <code class="docutils literal"><span class="pre">mongodb</span></code> database</p>
<dl class="class">
<dt id="requests_cache.backends.storage.mongodict.MongoDict">
<em class="property">class </em><code class="descclassname">requests_cache.backends.storage.mongodict.</code><code class="descname">MongoDict</code><span class="sig-paren">(</span><em>db_name</em>, <em>collection_name='mongo_dict_data'</em>, <em>connection=None</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.mongodict.MongoDict" title="Permalink to this definition">¶</a></dt>
<dd><p>MongoDict - a dictionary-like interface for <code class="docutils literal"><span class="pre">mongo</span></code> database</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>db_name</strong> – database name (be careful with production databases)</li>
<li><strong>collection_name</strong> – collection name (default: mongo_dict_data)</li>
<li><strong>connection</strong> – <code class="docutils literal"><span class="pre">pymongo.Connection</span></code> instance. If it’s <code class="docutils literal"><span class="pre">None</span></code>
(default) new connection with default options will
be created</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="requests_cache.backends.storage.mongodict.MongoPickleDict">
<em class="property">class </em><code class="descclassname">requests_cache.backends.storage.mongodict.</code><code class="descname">MongoPickleDict</code><span class="sig-paren">(</span><em>db_name</em>, <em>collection_name='mongo_dict_data'</em>, <em>connection=None</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.mongodict.MongoPickleDict" title="Permalink to this definition">¶</a></dt>
<dd><p>Same as <a class="reference internal" href="#requests_cache.backends.storage.mongodict.MongoDict" title="requests_cache.backends.storage.mongodict.MongoDict"><code class="xref py py-class docutils literal"><span class="pre">MongoDict</span></code></a>, but pickles values before saving</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>db_name</strong> – database name (be careful with production databases)</li>
<li><strong>collection_name</strong> – collection name (default: mongo_dict_data)</li>
<li><strong>connection</strong> – <code class="docutils literal"><span class="pre">pymongo.Connection</span></code> instance. If it’s <code class="docutils literal"><span class="pre">None</span></code>
(default) new connection with default options will
be created</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<span class="target" id="module-requests_cache.backends.storage.redisdict"></span><div class="section" id="requests-cache-backends-redisdict">
<h3>requests_cache.backends.redisdict<a class="headerlink" href="#requests-cache-backends-redisdict" title="Permalink to this headline">¶</a></h3>
<p>Dictionary-like objects for saving large data sets to <code class="docutils literal"><span class="pre">redis</span></code> key-store</p>
<dl class="class">
<dt id="requests_cache.backends.storage.redisdict.RedisDict">
<em class="property">class </em><code class="descclassname">requests_cache.backends.storage.redisdict.</code><code class="descname">RedisDict</code><span class="sig-paren">(</span><em>namespace</em>, <em>collection_name='redis_dict_data'</em>, <em>connection=None</em><span class="sig-paren">)</span><a class="headerlink" href="#requests_cache.backends.storage.redisdict.RedisDict" title="Permalink to this definition">¶</a></dt>
<dd><p>RedisDict - a dictionary-like interface for <code class="docutils literal"><span class="pre">redis</span></code> key-stores</p>
<p>The actual key name on the redis server will be
<code class="docutils literal"><span class="pre">namespace</span></code>:<code class="docutils literal"><span class="pre">collection_name</span></code></p>
<p>In order to deal with how redis stores data/keys,
everything, i.e. keys and data, must be pickled.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>namespace</strong> – namespace to use</li>
<li><strong>collection_name</strong> – name of the hash map stored in redis
(default: redis_dict_data)</li>
<li><strong>connection</strong> – <code class="docutils literal"><span class="pre">redis.StrictRedis</span></code> instance.
If it’s <code class="docutils literal"><span class="pre">None</span></code> (default), a new connection with
default options will be created</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">API</a><ul>
<li><a class="reference internal" href="#module-requests_cache.core">Public api</a><ul>
<li><a class="reference internal" href="#requests-cache-core">requests_cache.core</a></li>
</ul>
</li>
<li><a class="reference internal" href="#module-requests_cache.backends.base">Cache backends</a><ul>
<li><a class="reference internal" href="#requests-cache-backends-base">requests_cache.backends.base</a></li>
<li><a class="reference internal" href="#requests-cache-backends-sqlite">requests_cache.backends.sqlite</a></li>
<li><a class="reference internal" href="#requests-cache-backends-mongo">requests_cache.backends.mongo</a></li>
<li><a class="reference internal" href="#requests-cache-backends-redis">requests_cache.backends.redis</a></li>
</ul>
</li>
<li><a class="reference internal" href="#internal-modules-which-can-be-used-outside">Internal modules which can be used outside</a><ul>
<li><a class="reference internal" href="#requests-cache-backends-dbdict">requests_cache.backends.dbdict</a></li>
<li><a class="reference internal" href="#requests-cache-backends-mongodict">requests_cache.backends.mongodict</a></li>
<li><a class="reference internal" href="#requests-cache-backends-redisdict">requests_cache.backends.redisdict</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="user_guide.html"
title="previous chapter">User guide</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/api.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="user_guide.html" title="User guide"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">requests-cache 0.4.10 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2012, Roman Haritonov.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.4.
</div>
</body>
</html>
|