Debian Codegraph @

third_party/python/diskcache/diskcache-5.6.3.dist-info/METADATA

raw
1 Metadata-Version: 2.1
2 Name: diskcache
3 Version: 5.6.3
4 Summary: Disk Cache -- Disk and file backed persistent cache.
5 Home-page: http://www.grantjenks.com/docs/diskcache/
6 Author: Grant Jenks
7 Author-email: [email protected]
8 License: Apache 2.0
9 Project-URL: Documentation, http://www.grantjenks.com/docs/diskcache/
10 Project-URL: Funding, https://gum.co/diskcache
11 Project-URL: Source, https://github.com/grantjenks/python-diskcache
12 Project-URL: Tracker, https://github.com/grantjenks/python-diskcache/issues
13 Classifier: Development Status :: 5 - Production/Stable
14 Classifier: Intended Audience :: Developers
15 Classifier: License :: OSI Approved :: Apache Software License
16 Classifier: Natural Language :: English
17 Classifier: Programming Language :: Python
18 Classifier: Programming Language :: Python :: 3
19 Classifier: Programming Language :: Python :: 3.5
20 Classifier: Programming Language :: Python :: 3.6
21 Classifier: Programming Language :: Python :: 3.7
22 Classifier: Programming Language :: Python :: 3.8
23 Classifier: Programming Language :: Python :: 3.9
24 Classifier: Programming Language :: Python :: Implementation :: CPython
25 Requires-Python: >=3
26 License-File: LICENSE
27
28 DiskCache: Disk Backed Cache
29 ============================
30
31 `DiskCache`_ is an Apache2 licensed disk and file backed cache library, written
32 in pure-Python, and compatible with Django.
33
34 The cloud-based computing of 2023 puts a premium on memory. Gigabytes of empty
35 space is left on disks as processes vie for memory. Among these processes is
36 Memcached (and sometimes Redis) which is used as a cache. Wouldn't it be nice
37 to leverage empty disk space for caching?
38
39 Django is Python's most popular web framework and ships with several caching
40 backends. Unfortunately the file-based cache in Django is essentially
41 broken. The culling method is random and large caches repeatedly scan a cache
42 directory which slows linearly with growth. Can you really allow it to take
43 sixty milliseconds to store a key in a cache with a thousand items?
44
45 In Python, we can do better. And we can do it in pure-Python!
46
47 ::
48
49 In [1]: import pylibmc
50 In [2]: client = pylibmc.Client(['127.0.0.1'], binary=True)
51 In [3]: client[b'key'] = b'value'
52 In [4]: %timeit client[b'key']
53
54 10000 loops, best of 3: 25.4 µs per loop
55
56 In [5]: import diskcache as dc
57 In [6]: cache = dc.Cache('tmp')
58 In [7]: cache[b'key'] = b'value'
59 In [8]: %timeit cache[b'key']
60
61 100000 loops, best of 3: 11.8 µs per loop
62
63 **Note:** Micro-benchmarks have their place but are not a substitute for real
64 measurements. DiskCache offers cache benchmarks to defend its performance
65 claims. Micro-optimizations are avoided but your mileage may vary.
66
67 DiskCache efficiently makes gigabytes of storage space available for
68 caching. By leveraging rock-solid database libraries and memory-mapped files,
69 cache performance can match and exceed industry-standard solutions. There's no
70 need for a C compiler or running another process. Performance is a feature and
71 testing has 100% coverage with unit tests and hours of stress.
72
73 Testimonials
74 ------------
75
76 `Daren Hasenkamp`_, Founder --
77
78 "It's a useful, simple API, just like I love about Redis. It has reduced
79 the amount of queries hitting my Elasticsearch cluster by over 25% for a
80 website that gets over a million users/day (100+ hits/second)."
81
82 `Mathias Petermann`_, Senior Linux System Engineer --
83
84 "I implemented it into a wrapper for our Ansible lookup modules and we were
85 able to speed up some Ansible runs by almost 3 times. DiskCache is saving
86 us a ton of time."
87
88 Does your company or website use `DiskCache`_? Send us a `message
89 <[email protected]>`_ and let us know.
90
91 .. _`Daren Hasenkamp`: https://www.linkedin.com/in/daren-hasenkamp-93006438/
92 .. _`Mathias Petermann`: https://www.linkedin.com/in/mathias-petermann-a8aa273b/
93
94 Features
95 --------
96
97 - Pure-Python
98 - Fully Documented
99 - Benchmark comparisons (alternatives, Django cache backends)
100 - 100% test coverage
101 - Hours of stress testing
102 - Performance matters
103 - Django compatible API
104 - Thread-safe and process-safe
105 - Supports multiple eviction policies (LRU and LFU included)
106 - Keys support "tag" metadata and eviction
107 - Developed on Python 3.10
108 - Tested on CPython 3.6, 3.7, 3.8, 3.9, 3.10
109 - Tested on Linux, Mac OS X, and Windows
110 - Tested using GitHub Actions
111
112 .. image:: https://github.com/grantjenks/python-diskcache/workflows/integration/badge.svg
113 :target: https://github.com/grantjenks/python-diskcache/actions?query=workflow%3Aintegration
114
115 .. image:: https://github.com/grantjenks/python-diskcache/workflows/release/badge.svg
116 :target: https://github.com/grantjenks/python-diskcache/actions?query=workflow%3Arelease
117
118 Quickstart
119 ----------
120
121 Installing `DiskCache`_ is simple with `pip <http://www.pip-installer.org/>`_::
122
123 $ pip install diskcache
124
125 You can access documentation in the interpreter with Python's built-in help
126 function::
127
128 >>> import diskcache
129 >>> help(diskcache) # doctest: +SKIP
130
131 The core of `DiskCache`_ is three data types intended for caching. `Cache`_
132 objects manage a SQLite database and filesystem directory to store key and
133 value pairs. `FanoutCache`_ provides a sharding layer to utilize multiple
134 caches and `DjangoCache`_ integrates that with `Django`_::
135
136 >>> from diskcache import Cache, FanoutCache, DjangoCache
137 >>> help(Cache) # doctest: +SKIP
138 >>> help(FanoutCache) # doctest: +SKIP
139 >>> help(DjangoCache) # doctest: +SKIP
140
141 Built atop the caching data types, are `Deque`_ and `Index`_ which work as a
142 cross-process, persistent replacements for Python's ``collections.deque`` and
143 ``dict``. These implement the sequence and mapping container base classes::
144
145 >>> from diskcache import Deque, Index
146 >>> help(Deque) # doctest: +SKIP
147 >>> help(Index) # doctest: +SKIP
148
149 Finally, a number of `recipes`_ for cross-process synchronization are provided
150 using an underlying cache. Features like memoization with cache stampede
151 prevention, cross-process locking, and cross-process throttling are available::
152
153 >>> from diskcache import memoize_stampede, Lock, throttle
154 >>> help(memoize_stampede) # doctest: +SKIP
155 >>> help(Lock) # doctest: +SKIP
156 >>> help(throttle) # doctest: +SKIP
157
158 Python's docstrings are a quick way to get started but not intended as a
159 replacement for the `DiskCache Tutorial`_ and `DiskCache API Reference`_.
160
161 .. _`Cache`: http://www.grantjenks.com/docs/diskcache/tutorial.html#cache
162 .. _`FanoutCache`: http://www.grantjenks.com/docs/diskcache/tutorial.html#fanoutcache
163 .. _`DjangoCache`: http://www.grantjenks.com/docs/diskcache/tutorial.html#djangocache
164 .. _`Django`: https://www.djangoproject.com/
165 .. _`Deque`: http://www.grantjenks.com/docs/diskcache/tutorial.html#deque
166 .. _`Index`: http://www.grantjenks.com/docs/diskcache/tutorial.html#index
167 .. _`recipes`: http://www.grantjenks.com/docs/diskcache/tutorial.html#recipes
168
169 User Guide
170 ----------
171
172 For those wanting more details, this part of the documentation describes
173 tutorial, benchmarks, API, and development.
174
175 * `DiskCache Tutorial`_
176 * `DiskCache Cache Benchmarks`_
177 * `DiskCache DjangoCache Benchmarks`_
178 * `Case Study: Web Crawler`_
179 * `Case Study: Landing Page Caching`_
180 * `Talk: All Things Cached - SF Python 2017 Meetup`_
181 * `DiskCache API Reference`_
182 * `DiskCache Development`_
183
184 .. _`DiskCache Tutorial`: http://www.grantjenks.com/docs/diskcache/tutorial.html
185 .. _`DiskCache Cache Benchmarks`: http://www.grantjenks.com/docs/diskcache/cache-benchmarks.html
186 .. _`DiskCache DjangoCache Benchmarks`: http://www.grantjenks.com/docs/diskcache/djangocache-benchmarks.html
187 .. _`Talk: All Things Cached - SF Python 2017 Meetup`: http://www.grantjenks.com/docs/diskcache/sf-python-2017-meetup-talk.html
188 .. _`Case Study: Web Crawler`: http://www.grantjenks.com/docs/diskcache/case-study-web-crawler.html
189 .. _`Case Study: Landing Page Caching`: http://www.grantjenks.com/docs/diskcache/case-study-landing-page-caching.html
190 .. _`DiskCache API Reference`: http://www.grantjenks.com/docs/diskcache/api.html
191 .. _`DiskCache Development`: http://www.grantjenks.com/docs/diskcache/development.html
192
193 Comparisons
194 -----------
195
196 Comparisons to popular projects related to `DiskCache`_.
197
198 Key-Value Stores
199 ................
200
201 `DiskCache`_ is mostly a simple key-value store. Feature comparisons with four
202 other projects are shown in the tables below.
203
204 * `dbm`_ is part of Python's standard library and implements a generic
205 interface to variants of the DBM database — dbm.gnu or dbm.ndbm. If none of
206 these modules is installed, the slow-but-simple dbm.dumb is used.
207 * `shelve`_ is part of Python's standard library and implements a “shelf” as a
208 persistent, dictionary-like object. The difference with “dbm” databases is
209 that the values can be anything that the pickle module can handle.
210 * `sqlitedict`_ is a lightweight wrapper around Python's sqlite3 database with
211 a simple, Pythonic dict-like interface and support for multi-thread
212 access. Keys are arbitrary strings, values arbitrary pickle-able objects.
213 * `pickleDB`_ is a lightweight and simple key-value store. It is built upon
214 Python's simplejson module and was inspired by Redis. It is licensed with the
215 BSD three-clause license.
216
217 .. _`dbm`: https://docs.python.org/3/library/dbm.html
218 .. _`shelve`: https://docs.python.org/3/library/shelve.html
219 .. _`sqlitedict`: https://github.com/RaRe-Technologies/sqlitedict
220 .. _`pickleDB`: https://pythonhosted.org/pickleDB/
221
222 **Features**
223
224 ================ ============= ========= ========= ============ ============
225 Feature diskcache dbm shelve sqlitedict pickleDB
226 ================ ============= ========= ========= ============ ============
227 Atomic? Always Maybe Maybe Maybe No
228 Persistent? Yes Yes Yes Yes Yes
229 Thread-safe? Yes No No Yes No
230 Process-safe? Yes No No Maybe No
231 Backend? SQLite DBM DBM SQLite File
232 Serialization? Customizable None Pickle Customizable JSON
233 Data Types? Mapping/Deque Mapping Mapping Mapping Mapping
234 Ordering? Insert/Sorted None None None None
235 Eviction? LRU/LFU/more None None None None
236 Vacuum? Automatic Maybe Maybe Manual Automatic
237 Transactions? Yes No No Maybe No
238 Multiprocessing? Yes No No No No
239 Forkable? Yes No No No No
240 Metadata? Yes No No No No
241 ================ ============= ========= ========= ============ ============
242
243 **Quality**
244
245 ================ ============= ========= ========= ============ ============
246 Project diskcache dbm shelve sqlitedict pickleDB
247 ================ ============= ========= ========= ============ ============
248 Tests? Yes Yes Yes Yes Yes
249 Coverage? Yes Yes Yes Yes No
250 Stress? Yes No No No No
251 CI Tests? Linux/Windows Yes Yes Linux No
252 Python? 2/3/PyPy All All 2/3 2/3
253 License? Apache2 Python Python Apache2 3-Clause BSD
254 Docs? Extensive Summary Summary Readme Summary
255 Benchmarks? Yes No No No No
256 Sources? GitHub GitHub GitHub GitHub GitHub
257 Pure-Python? Yes Yes Yes Yes Yes
258 Server? No No No No No
259 Integrations? Django None None None None
260 ================ ============= ========= ========= ============ ============
261
262 **Timings**
263
264 These are rough measurements. See `DiskCache Cache Benchmarks`_ for more
265 rigorous data.
266
267 ================ ============= ========= ========= ============ ============
268 Project diskcache dbm shelve sqlitedict pickleDB
269 ================ ============= ========= ========= ============ ============
270 get 25 µs 36 µs 41 µs 513 µs 92 µs
271 set 198 µs 900 µs 928 µs 697 µs 1,020 µs
272 delete 248 µs 740 µs 702 µs 1,717 µs 1,020 µs
273 ================ ============= ========= ========= ============ ============
274
275 Caching Libraries
276 .................
277
278 * `joblib.Memory`_ provides caching functions and works by explicitly saving
279 the inputs and outputs to files. It is designed to work with non-hashable and
280 potentially large input and output data types such as numpy arrays.
281 * `klepto`_ extends Python’s `lru_cache` to utilize different keymaps and
282 alternate caching algorithms, such as `lfu_cache` and `mru_cache`. Klepto
283 uses a simple dictionary-sytle interface for all caches and archives.
284
285 .. _`klepto`: https://pypi.org/project/klepto/
286 .. _`joblib.Memory`: https://joblib.readthedocs.io/en/latest/memory.html
287
288 Data Structures
289 ...............
290
291 * `dict`_ is a mapping object that maps hashable keys to arbitrary
292 values. Mappings are mutable objects. There is currently only one standard
293 Python mapping type, the dictionary.
294 * `pandas`_ is a Python package providing fast, flexible, and expressive data
295 structures designed to make working with “relational” or “labeled” data both
296 easy and intuitive.
297 * `Sorted Containers`_ is an Apache2 licensed sorted collections library,
298 written in pure-Python, and fast as C-extensions. Sorted Containers
299 implements sorted list, sorted dictionary, and sorted set data types.
300
301 .. _`dict`: https://docs.python.org/3/library/stdtypes.html#typesmapping
302 .. _`pandas`: https://pandas.pydata.org/
303 .. _`Sorted Containers`: http://www.grantjenks.com/docs/sortedcontainers/
304
305 Pure-Python Databases
306 .....................
307
308 * `ZODB`_ supports an isomorphic interface for database operations which means
309 there's little impact on your code to make objects persistent and there's no
310 database mapper that partially hides the datbase.
311 * `CodernityDB`_ is an open source, pure-Python, multi-platform, schema-less,
312 NoSQL database and includes an HTTP server version, and a Python client
313 library that aims to be 100% compatible with the embedded version.
314 * `TinyDB`_ is a tiny, document oriented database optimized for your
315 happiness. If you need a simple database with a clean API that just works
316 without lots of configuration, TinyDB might be the right choice for you.
317
318 .. _`ZODB`: http://www.zodb.org/
319 .. _`CodernityDB`: https://pypi.org/project/CodernityDB/
320 .. _`TinyDB`: https://tinydb.readthedocs.io/
321
322 Object Relational Mappings (ORM)
323 ................................
324
325 * `Django ORM`_ provides models that are the single, definitive source of
326 information about data and contains the essential fields and behaviors of the
327 stored data. Generally, each model maps to a single SQL database table.
328 * `SQLAlchemy`_ is the Python SQL toolkit and Object Relational Mapper that
329 gives application developers the full power and flexibility of SQL. It
330 provides a full suite of well known enterprise-level persistence patterns.
331 * `Peewee`_ is a simple and small ORM. It has few (but expressive) concepts,
332 making it easy to learn and intuitive to use. Peewee supports Sqlite, MySQL,
333 and PostgreSQL with tons of extensions.
334 * `SQLObject`_ is a popular Object Relational Manager for providing an object
335 interface to your database, with tables as classes, rows as instances, and
336 columns as attributes.
337 * `Pony ORM`_ is a Python ORM with beautiful query syntax. Use Python syntax
338 for interacting with the database. Pony translates such queries into SQL and
339 executes them in the database in the most efficient way.
340
341 .. _`Django ORM`: https://docs.djangoproject.com/en/dev/topics/db/
342 .. _`SQLAlchemy`: https://www.sqlalchemy.org/
343 .. _`Peewee`: http://docs.peewee-orm.com/
344 .. _`SQLObject`: http://sqlobject.org/
345 .. _`Pony ORM`: https://ponyorm.com/
346
347 SQL Databases
348 .............
349
350 * `SQLite`_ is part of Python's standard library and provides a lightweight
351 disk-based database that doesn’t require a separate server process and allows
352 accessing the database using a nonstandard variant of the SQL query language.
353 * `MySQL`_ is one of the world’s most popular open source databases and has
354 become a leading database choice for web-based applications. MySQL includes a
355 standardized database driver for Python platforms and development.
356 * `PostgreSQL`_ is a powerful, open source object-relational database system
357 with over 30 years of active development. Psycopg is the most popular
358 PostgreSQL adapter for the Python programming language.
359 * `Oracle DB`_ is a relational database management system (RDBMS) from the
360 Oracle Corporation. Originally developed in 1977, Oracle DB is one of the
361 most trusted and widely used enterprise relational database engines.
362 * `Microsoft SQL Server`_ is a relational database management system developed
363 by Microsoft. As a database server, it stores and retrieves data as requested
364 by other software applications.
365
366 .. _`SQLite`: https://docs.python.org/3/library/sqlite3.html
367 .. _`MySQL`: https://dev.mysql.com/downloads/connector/python/
368 .. _`PostgreSQL`: http://initd.org/psycopg/
369 .. _`Oracle DB`: https://pypi.org/project/cx_Oracle/
370 .. _`Microsoft SQL Server`: https://pypi.org/project/pyodbc/
371
372 Other Databases
373 ...............
374
375 * `Memcached`_ is free and open source, high-performance, distributed memory
376 object caching system, generic in nature, but intended for use in speeding up
377 dynamic web applications by alleviating database load.
378 * `Redis`_ is an open source, in-memory data structure store, used as a
379 database, cache and message broker. It supports data structures such as
380 strings, hashes, lists, sets, sorted sets with range queries, and more.
381 * `MongoDB`_ is a cross-platform document-oriented database program. Classified
382 as a NoSQL database program, MongoDB uses JSON-like documents with
383 schema. PyMongo is the recommended way to work with MongoDB from Python.
384 * `LMDB`_ is a lightning-fast, memory-mapped database. With memory-mapped
385 files, it has the read performance of a pure in-memory database while
386 retaining the persistence of standard disk-based databases.
387 * `BerkeleyDB`_ is a software library intended to provide a high-performance
388 embedded database for key/value data. Berkeley DB is a programmatic toolkit
389 that provides built-in database support for desktop and server applications.
390 * `LevelDB`_ is a fast key-value storage library written at Google that
391 provides an ordered mapping from string keys to string values. Data is stored
392 sorted by key and users can provide a custom comparison function.
393
394 .. _`Memcached`: https://pypi.org/project/python-memcached/
395 .. _`MongoDB`: https://api.mongodb.com/python/current/
396 .. _`Redis`: https://redis.io/clients#python
397 .. _`LMDB`: https://lmdb.readthedocs.io/
398 .. _`BerkeleyDB`: https://pypi.org/project/bsddb3/
399 .. _`LevelDB`: https://plyvel.readthedocs.io/
400
401 Reference
402 ---------
403
404 * `DiskCache Documentation`_
405 * `DiskCache at PyPI`_
406 * `DiskCache at GitHub`_
407 * `DiskCache Issue Tracker`_
408
409 .. _`DiskCache Documentation`: http://www.grantjenks.com/docs/diskcache/
410 .. _`DiskCache at PyPI`: https://pypi.python.org/pypi/diskcache/
411 .. _`DiskCache at GitHub`: https://github.com/grantjenks/python-diskcache/
412 .. _`DiskCache Issue Tracker`: https://github.com/grantjenks/python-diskcache/issues/
413
414 License
415 -------
416
417 Copyright 2016-2023 Grant Jenks
418
419 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
420 this file except in compliance with the License. You may obtain a copy of the
421 License at
422
423 http://www.apache.org/licenses/LICENSE-2.0
424
425 Unless required by applicable law or agreed to in writing, software distributed
426 under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
427 CONDITIONS OF ANY KIND, either express or implied. See the License for the
428 specific language governing permissions and limitations under the License.
429
430 .. _`DiskCache`: http://www.grantjenks.com/docs/diskcache/