One function

CachingMiddleware in msiemens/tinydb

The author described this change as Fix problem with caching and existing data. It counts as a record because the check below fails on the code as it stood at ac58fea35 and passes on 45a4d4b31, with nothing else changed between the two runs.

Fix saved2015-02-03
Sharing licenceMIT · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Add some caching to TinyDB. This Middleware aims to improve the performance of TinyDB by writing only the last DB state every :attr:`WRITE_CACHE_SIZE` time and reading always from cache.

The change

2121
2222 def read(self):
2323 if self.cache is None:
24- raise ValueError
24+ self.cache = self.storage.read()
2525 return self.cache
2626
2727 def write(self, data):

The check that tells the two apart

failpass·tests/test_middlewares.py::test_caching_json_write

Check file tests/test_middlewares.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itac58fea350578e889e71cf92c6345adf3fcab061
Broken version dated2015-01-09
Moduletinydb.middlewares
Units changedCachingMiddleware
Fingerprintffe6651efe6efb54
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in msiemens/tinydb