/usr/share/doc/python-limits-doc/html/api.html is in python-limits-doc 1.2.1-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 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API — limits unknown documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="limits unknown documentation" href="index.html"/>
<link rel="next" title="Changelog" href="changelog.html"/>
<link rel="prev" title="Rate limiting strategies" href="strategies.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> limits
</a>
<div class="version">
unknown
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="string-notation.html">Rate limit string notation</a></li>
<li class="toctree-l1"><a class="reference internal" href="custom-storage.html">Custom storage backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="storage.html">Storage Backends</a></li>
<li class="toctree-l1"><a class="reference internal" href="strategies.html">Rate limiting strategies</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#storage">Storage</a></li>
<li class="toctree-l2"><a class="reference internal" href="#strategies">Strategies</a></li>
<li class="toctree-l2"><a class="reference internal" href="#rate-limits">Rate Limits</a></li>
<li class="toctree-l2"><a class="reference internal" href="#exceptions">Exceptions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">limits</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>API</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/api.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="api">
<h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
<div class="section" id="storage">
<h2>Storage<a class="headerlink" href="#storage" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="limits.storage.Storage">
<em class="property">class </em><code class="descclassname">limits.storage.</code><code class="descname">Storage</code><span class="sig-paren">(</span><em>uri=None</em>, <em>**options</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#Storage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.Storage" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
<p>Base class to extend when implementing a storage backend.</p>
<dl class="method">
<dt id="limits.storage.Storage.check">
<code class="descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#Storage.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.Storage.check" title="Permalink to this definition">¶</a></dt>
<dd><p>check if storage is healthy</p>
</dd></dl>
<dl class="method">
<dt id="limits.storage.Storage.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#Storage.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.Storage.get" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the counter value for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.Storage.get_expiry">
<code class="descname">get_expiry</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#Storage.get_expiry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.Storage.get_expiry" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the expiry for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.Storage.incr">
<code class="descname">incr</code><span class="sig-paren">(</span><em>key</em>, <em>expiry</em>, <em>elastic_expiry=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#Storage.incr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.Storage.incr" title="Permalink to this definition">¶</a></dt>
<dd><p>increments the counter for a given rate limit key</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> (<em>str</em>) – the key to increment</li>
<li><strong>expiry</strong> (<em>int</em>) – amount in seconds for the key to expire in</li>
<li><strong>elastic_expiry</strong> (<em>bool</em>) – whether to keep extending the rate limit
window every hit.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.Storage.reset">
<code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#Storage.reset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.Storage.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>reset storage to clear limits</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.storage.MemoryStorage">
<em class="property">class </em><code class="descclassname">limits.storage.</code><code class="descname">MemoryStorage</code><span class="sig-paren">(</span><em>uri=None</em>, <em>**_</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#limits.storage.Storage" title="limits.storage.Storage"><code class="xref py py-class docutils literal"><span class="pre">limits.storage.Storage</span></code></a></p>
<p>rate limit storage using <code class="xref py py-class docutils literal"><span class="pre">collections.Counter</span></code>
as an in memory storage for fixed and elastic window strategies,
and a simple list to implement moving window strategy.</p>
<dl class="method">
<dt id="limits.storage.MemoryStorage.acquire_entry">
<code class="descname">acquire_entry</code><span class="sig-paren">(</span><em>key</em>, <em>limit</em>, <em>expiry</em>, <em>no_add=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.acquire_entry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.acquire_entry" title="Permalink to this definition">¶</a></dt>
<dd><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> (<em>str</em>) – rate limit key to acquire an entry in</li>
<li><strong>limit</strong> (<em>int</em>) – amount of entries allowed</li>
<li><strong>expiry</strong> (<em>int</em>) – expiry of the entry</li>
<li><strong>no_add</strong> (<em>bool</em>) – if False an entry is not actually acquired but instead
serves as a ‘check’</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemoryStorage.check">
<code class="descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.check" title="Permalink to this definition">¶</a></dt>
<dd><p>check if storage is healthy</p>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemoryStorage.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.get" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the counter value for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemoryStorage.get_expiry">
<code class="descname">get_expiry</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.get_expiry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.get_expiry" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the expiry for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemoryStorage.get_moving_window">
<code class="descname">get_moving_window</code><span class="sig-paren">(</span><em>key</em>, <em>limit</em>, <em>expiry</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.get_moving_window"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.get_moving_window" title="Permalink to this definition">¶</a></dt>
<dd><p>returns the starting point and the number of entries in the moving window</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> (<em>str</em>) – rate limit key</li>
<li><strong>expiry</strong> (<em>int</em>) – expiry of entry</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemoryStorage.get_num_acquired">
<code class="descname">get_num_acquired</code><span class="sig-paren">(</span><em>key</em>, <em>expiry</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.get_num_acquired"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.get_num_acquired" title="Permalink to this definition">¶</a></dt>
<dd><p>returns the number of entries already acquired</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> (<em>str</em>) – rate limit key to acquire an entry in</li>
<li><strong>expiry</strong> (<em>int</em>) – expiry of the entry</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemoryStorage.incr">
<code class="descname">incr</code><span class="sig-paren">(</span><em>key</em>, <em>expiry</em>, <em>elastic_expiry=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemoryStorage.incr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemoryStorage.incr" title="Permalink to this definition">¶</a></dt>
<dd><p>increments the counter for a given rate limit key</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> (<em>str</em>) – the key to increment</li>
<li><strong>expiry</strong> (<em>int</em>) – amount in seconds for the key to expire in</li>
<li><strong>elastic_expiry</strong> (<em>bool</em>) – whether to keep extending the rate limit
window every hit.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.storage.RedisStorage">
<em class="property">class </em><code class="descclassname">limits.storage.</code><code class="descname">RedisStorage</code><span class="sig-paren">(</span><em>uri</em>, <em>**_</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.storage.RedisInteractor</span></code>, <a class="reference internal" href="#limits.storage.Storage" title="limits.storage.Storage"><code class="xref py py-class docutils literal"><span class="pre">limits.storage.Storage</span></code></a></p>
<p>rate limit storage with redis as backend</p>
<dl class="method">
<dt id="limits.storage.RedisStorage.acquire_entry">
<code class="descname">acquire_entry</code><span class="sig-paren">(</span><em>key</em>, <em>limit</em>, <em>expiry</em>, <em>no_add=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage.acquire_entry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage.acquire_entry" title="Permalink to this definition">¶</a></dt>
<dd><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> (<em>str</em>) – rate limit key to acquire an entry in</li>
<li><strong>limit</strong> (<em>int</em>) – amount of entries allowed</li>
<li><strong>expiry</strong> (<em>int</em>) – expiry of the entry</li>
<li><strong>no_add</strong> (<em>bool</em>) – if False an entry is not actually acquired but instead
serves as a ‘check’</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisStorage.check">
<code class="descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage.check" title="Permalink to this definition">¶</a></dt>
<dd><p>check if storage is healthy</p>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisStorage.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage.get" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the counter value for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisStorage.get_expiry">
<code class="descname">get_expiry</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage.get_expiry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage.get_expiry" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the expiry for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisStorage.incr">
<code class="descname">incr</code><span class="sig-paren">(</span><em>key</em>, <em>expiry</em>, <em>elastic_expiry=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage.incr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage.incr" title="Permalink to this definition">¶</a></dt>
<dd><p>increments the counter for a given rate limit key</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> (<em>str</em>) – the key to increment</li>
<li><strong>expiry</strong> (<em>int</em>) – amount in seconds for the key to expire in</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisStorage.reset">
<code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisStorage.reset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisStorage.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>WARNING, this operation was designed to be fast, but was not tested
on a large production based system. Be careful with its usage as it
could be slow on very large data sets.</p>
<p>This function calls a Lua Script to delete keys prefixed with ‘LIMITER’
in block of 5000.</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.storage.RedisSentinelStorage">
<em class="property">class </em><code class="descclassname">limits.storage.</code><code class="descname">RedisSentinelStorage</code><span class="sig-paren">(</span><em>uri</em>, <em>**options</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisSentinelStorage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisSentinelStorage" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#limits.storage.RedisStorage" title="limits.storage.RedisStorage"><code class="xref py py-class docutils literal"><span class="pre">limits.storage.RedisStorage</span></code></a></p>
<p>rate limit storage with redis sentinel as backend</p>
<dl class="method">
<dt id="limits.storage.RedisSentinelStorage.check">
<code class="descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisSentinelStorage.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisSentinelStorage.check" title="Permalink to this definition">¶</a></dt>
<dd><p>check if storage is healthy</p>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisSentinelStorage.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisSentinelStorage.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisSentinelStorage.get" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the counter value for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.RedisSentinelStorage.get_expiry">
<code class="descname">get_expiry</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#RedisSentinelStorage.get_expiry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.RedisSentinelStorage.get_expiry" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the expiry for</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.storage.MemcachedStorage">
<em class="property">class </em><code class="descclassname">limits.storage.</code><code class="descname">MemcachedStorage</code><span class="sig-paren">(</span><em>uri</em>, <em>**options</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemcachedStorage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemcachedStorage" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#limits.storage.Storage" title="limits.storage.Storage"><code class="xref py py-class docutils literal"><span class="pre">limits.storage.Storage</span></code></a></p>
<p>rate limit storage with memcached as backend</p>
<dl class="method">
<dt id="limits.storage.MemcachedStorage.check">
<code class="descname">check</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemcachedStorage.check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemcachedStorage.check" title="Permalink to this definition">¶</a></dt>
<dd><p>check if storage is healthy</p>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemcachedStorage.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemcachedStorage.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemcachedStorage.get" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the counter value for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemcachedStorage.get_client">
<code class="descname">get_client</code><span class="sig-paren">(</span><em>module</em>, <em>hosts</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemcachedStorage.get_client"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemcachedStorage.get_client" title="Permalink to this definition">¶</a></dt>
<dd><p>returns a memcached client.
:param module: the memcached module
:param hosts: list of memcached hosts
:return:</p>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemcachedStorage.get_expiry">
<code class="descname">get_expiry</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemcachedStorage.get_expiry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemcachedStorage.get_expiry" title="Permalink to this definition">¶</a></dt>
<dd><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>key</strong> (<em>str</em>) – the key to get the expiry for</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.storage.MemcachedStorage.incr">
<code class="descname">incr</code><span class="sig-paren">(</span><em>key</em>, <em>expiry</em>, <em>elastic_expiry=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#MemcachedStorage.incr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.MemcachedStorage.incr" title="Permalink to this definition">¶</a></dt>
<dd><p>increments the counter for a given rate limit key</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> (<em>str</em>) – the key to increment</li>
<li><strong>expiry</strong> (<em>int</em>) – amount in seconds for the key to expire in</li>
<li><strong>elastic_expiry</strong> (<em>bool</em>) – whether to keep extending the rate limit
window every hit.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="limits.storage.MemcachedStorage.storage">
<code class="descname">storage</code><a class="headerlink" href="#limits.storage.MemcachedStorage.storage" title="Permalink to this definition">¶</a></dt>
<dd><p>lazily creates a memcached client instance using a thread local</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="limits.storage.storage_from_string">
<code class="descclassname">limits.storage.</code><code class="descname">storage_from_string</code><span class="sig-paren">(</span><em>storage_string</em>, <em>**options</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/storage.html#storage_from_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.storage.storage_from_string" title="Permalink to this definition">¶</a></dt>
<dd><p>factory function to get an instance of the storage class based
on the uri of the storage</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>storage_string</strong> – a string of the form method://host:port</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">an instance of <code class="xref py py-class docutils literal"><span class="pre">flask_limiter.storage.Storage</span></code></td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="strategies">
<h2>Strategies<a class="headerlink" href="#strategies" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="limits.strategies.RateLimiter">
<em class="property">class </em><code class="descclassname">limits.strategies.</code><code class="descname">RateLimiter</code><span class="sig-paren">(</span><em>storage</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#RateLimiter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.RateLimiter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
<dl class="method">
<dt id="limits.strategies.RateLimiter.get_window_stats">
<code class="descname">get_window_stats</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#RateLimiter.get_window_stats"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.RateLimiter.get_window_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>returns the number of requests remaining and reset of this limit.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple (reset time (int), remaining (int))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.strategies.RateLimiter.hit">
<code class="descname">hit</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#RateLimiter.hit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.RateLimiter.hit" title="Permalink to this definition">¶</a></dt>
<dd><p>creates a hit on the rate limit and returns True if successful.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.strategies.RateLimiter.test">
<code class="descname">test</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#RateLimiter.test"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.RateLimiter.test" title="Permalink to this definition">¶</a></dt>
<dd><p>checks the rate limit and returns True if it is not
currently exceeded.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.strategies.FixedWindowRateLimiter">
<em class="property">class </em><code class="descclassname">limits.strategies.</code><code class="descname">FixedWindowRateLimiter</code><span class="sig-paren">(</span><em>storage</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#FixedWindowRateLimiter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.FixedWindowRateLimiter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#limits.strategies.RateLimiter" title="limits.strategies.RateLimiter"><code class="xref py py-class docutils literal"><span class="pre">limits.strategies.RateLimiter</span></code></a></p>
<p>Reference: <a class="reference internal" href="strategies.html#fixed-window"><span class="std std-ref">Fixed Window</span></a></p>
<dl class="method">
<dt id="limits.strategies.FixedWindowRateLimiter.get_window_stats">
<code class="descname">get_window_stats</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#FixedWindowRateLimiter.get_window_stats"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.FixedWindowRateLimiter.get_window_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>returns the number of requests remaining and reset of this limit.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple (reset time (int), remaining (int))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.strategies.FixedWindowRateLimiter.hit">
<code class="descname">hit</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#FixedWindowRateLimiter.hit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.FixedWindowRateLimiter.hit" title="Permalink to this definition">¶</a></dt>
<dd><p>creates a hit on the rate limit and returns True if successful.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.strategies.FixedWindowRateLimiter.test">
<code class="descname">test</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#FixedWindowRateLimiter.test"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.FixedWindowRateLimiter.test" title="Permalink to this definition">¶</a></dt>
<dd><p>checks the rate limit and returns True if it is not
currently exceeded.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.strategies.FixedWindowElasticExpiryRateLimiter">
<em class="property">class </em><code class="descclassname">limits.strategies.</code><code class="descname">FixedWindowElasticExpiryRateLimiter</code><span class="sig-paren">(</span><em>storage</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#FixedWindowElasticExpiryRateLimiter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.FixedWindowElasticExpiryRateLimiter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#limits.strategies.FixedWindowRateLimiter" title="limits.strategies.FixedWindowRateLimiter"><code class="xref py py-class docutils literal"><span class="pre">limits.strategies.FixedWindowRateLimiter</span></code></a></p>
<p>Reference: <a class="reference internal" href="strategies.html#fixed-window-elastic"><span class="std std-ref">Fixed Window with Elastic Expiry</span></a></p>
<dl class="method">
<dt id="limits.strategies.FixedWindowElasticExpiryRateLimiter.hit">
<code class="descname">hit</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#FixedWindowElasticExpiryRateLimiter.hit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.FixedWindowElasticExpiryRateLimiter.hit" title="Permalink to this definition">¶</a></dt>
<dd><p>creates a hit on the rate limit and returns True if successful.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.strategies.MovingWindowRateLimiter">
<em class="property">class </em><code class="descclassname">limits.strategies.</code><code class="descname">MovingWindowRateLimiter</code><span class="sig-paren">(</span><em>storage</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#MovingWindowRateLimiter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.MovingWindowRateLimiter" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#limits.strategies.RateLimiter" title="limits.strategies.RateLimiter"><code class="xref py py-class docutils literal"><span class="pre">limits.strategies.RateLimiter</span></code></a></p>
<p>Reference: <a class="reference internal" href="strategies.html#moving-window"><span class="std std-ref">Moving Window</span></a></p>
<dl class="method">
<dt id="limits.strategies.MovingWindowRateLimiter.get_window_stats">
<code class="descname">get_window_stats</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#MovingWindowRateLimiter.get_window_stats"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.MovingWindowRateLimiter.get_window_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>returns the number of requests remaining within this limit.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">tuple (reset time (int), remaining (int))</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.strategies.MovingWindowRateLimiter.hit">
<code class="descname">hit</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#MovingWindowRateLimiter.hit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.MovingWindowRateLimiter.hit" title="Permalink to this definition">¶</a></dt>
<dd><p>creates a hit on the rate limit and returns True if successful.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.strategies.MovingWindowRateLimiter.test">
<code class="descname">test</code><span class="sig-paren">(</span><em>item</em>, <em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/strategies.html#MovingWindowRateLimiter.test"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.strategies.MovingWindowRateLimiter.test" title="Permalink to this definition">¶</a></dt>
<dd><p>checks the rate limit and returns True if it is not
currently exceeded.</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>item</strong> – a <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instance</li>
<li><strong>identifiers</strong> – variable list of strings to uniquely identify the
limit</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">True/False</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="rate-limits">
<h2>Rate Limits<a class="headerlink" href="#rate-limits" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="limits.RateLimitItem">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItem</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItem"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItem" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
<p>defines a Rate limited resource which contains the characteristic
namespace, amount and granularity multiples of the rate limiting window.</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>amount</strong> (<em>int</em>) – the rate limit amount</li>
<li><strong>multiples</strong> (<em>int</em>) – multiple of the ‘per’ granularity (e.g. ‘n’ per ‘m’ seconds)</li>
<li><strong>namespace</strong> (<em>string</em>) – category for the specific rate limit</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="classmethod">
<dt id="limits.RateLimitItem.check_granularity_string">
<em class="property">classmethod </em><code class="descname">check_granularity_string</code><span class="sig-paren">(</span><em>granularity_string</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItem.check_granularity_string"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItem.check_granularity_string" title="Permalink to this definition">¶</a></dt>
<dd><p>checks if this instance matches a granularity string
of type ‘n per hour’ etc.</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">Returns:</th><td class="field-body">True/False</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.RateLimitItem.get_expiry">
<code class="descname">get_expiry</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItem.get_expiry"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItem.get_expiry" title="Permalink to this definition">¶</a></dt>
<dd><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">Returns:</th><td class="field-body">the size of the window in seconds.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="limits.RateLimitItem.key_for">
<code class="descname">key_for</code><span class="sig-paren">(</span><em>*identifiers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItem.key_for"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItem.key_for" title="Permalink to this definition">¶</a></dt>
<dd><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>identifiers</strong> – a list of strings to append to the key</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a string key identifying this resource with
each identifier appended with a ‘/’ delimiter.</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="limits.RateLimitItemPerYear">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItemPerYear</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItemPerYear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItemPerYear" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.limits.RateLimitItem</span></code></p>
<p>per year rate limited resource.</p>
</dd></dl>
<dl class="class">
<dt id="limits.RateLimitItemPerMonth">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItemPerMonth</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItemPerMonth"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItemPerMonth" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.limits.RateLimitItem</span></code></p>
<p>per month rate limited resource.</p>
</dd></dl>
<dl class="class">
<dt id="limits.RateLimitItemPerDay">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItemPerDay</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItemPerDay"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItemPerDay" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.limits.RateLimitItem</span></code></p>
<p>per day rate limited resource.</p>
</dd></dl>
<dl class="class">
<dt id="limits.RateLimitItemPerHour">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItemPerHour</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItemPerHour"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItemPerHour" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.limits.RateLimitItem</span></code></p>
<p>per hour rate limited resource.</p>
</dd></dl>
<dl class="class">
<dt id="limits.RateLimitItemPerMinute">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItemPerMinute</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItemPerMinute"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItemPerMinute" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.limits.RateLimitItem</span></code></p>
<p>per minute rate limited resource.</p>
</dd></dl>
<dl class="class">
<dt id="limits.RateLimitItemPerSecond">
<em class="property">class </em><code class="descclassname">limits.</code><code class="descname">RateLimitItemPerSecond</code><span class="sig-paren">(</span><em>amount</em>, <em>multiples=1</em>, <em>namespace='LIMITER'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/limits.html#RateLimitItemPerSecond"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.RateLimitItemPerSecond" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">limits.limits.RateLimitItem</span></code></p>
<p>per second rate limited resource.</p>
</dd></dl>
<dl class="function">
<dt id="limits.parse">
<code class="descclassname">limits.</code><code class="descname">parse</code><span class="sig-paren">(</span><em>limit_string</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/util.html#parse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.parse" title="Permalink to this definition">¶</a></dt>
<dd><p>parses a single rate limit in string notation (e.g. ‘1/second’ or ‘1 per second’</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>limit_string</strong> (<em>string</em>) – rate limit string using <a class="reference internal" href="string-notation.html#ratelimit-string"><span class="std std-ref">Rate limit string notation</span></a></td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><strong>ValueError</strong> – if the string notation is invalid.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">an instance of <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="limits.parse_many">
<code class="descclassname">limits.</code><code class="descname">parse_many</code><span class="sig-paren">(</span><em>limit_string</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/limits/util.html#parse_many"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.parse_many" title="Permalink to this definition">¶</a></dt>
<dd><p>parses rate limits in string notation containing multiple rate limits
(e.g. ‘1/second; 5/minute’)</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>limit_string</strong> (<em>string</em>) – rate limit string using <a class="reference internal" href="string-notation.html#ratelimit-string"><span class="std std-ref">Rate limit string notation</span></a></td>
</tr>
<tr class="field-even field"><th class="field-name">Raises:</th><td class="field-body"><strong>ValueError</strong> – if the string notation is invalid.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">a list of <a class="reference internal" href="#limits.RateLimitItem" title="limits.RateLimitItem"><code class="xref py py-class docutils literal"><span class="pre">RateLimitItem</span></code></a> instances.</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="exceptions">
<h2>Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h2>
<dl class="exception">
<dt id="limits.errors.ConfigurationError">
<em class="property">exception </em><code class="descclassname">limits.errors.</code><code class="descname">ConfigurationError</code><a class="reference internal" href="_modules/limits/errors.html#ConfigurationError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#limits.errors.ConfigurationError" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">Exception</span></code></p>
<p>exception raised when a configuration problem
is encountered</p>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="changelog.html" class="btn btn-neutral float-right" title="Changelog" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="strategies.html" class="btn btn-neutral" title="Rate limiting strategies" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2017, Ali-Akber Saifee.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'unknown',
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>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|