summary refs log tree commit diff
path: root/tests/util/caches (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use inline type hints in `tests/` (#10350)Jonathan de Jong2021-07-131-1/+1
| | | | | | | | This PR is tantamount to running: python3.8 -m com2ann -v 6 tests/ (com2ann requires python 3.8 to run)
* Extend `ResponseCache` to pass a context object into the callback (#10157)Richard van der Hoff2021-06-141-7/+68
| | | | | This is the first of two PRs which seek to address #8518. This first PR lays the groundwork by extending ResponseCache; a second PR (#10158) will update the SyncHandler to actually use it, and fix the bug. The idea here is that we allow the callback given to ResponseCache.wrap to decide whether its result should be cached or not. We do that by (optionally) passing a ResponseCacheContext into it, which it can modify.
* Combine `LruCache.invalidate` and `invalidate_many` (#9973)Richard van der Hoff2021-05-271-3/+3
| | | | | | | | | | * Make `invalidate` and `invalidate_many` do the same thing ... so that we can do either over the invalidation replication stream, and also because they always confused me a bit. * Kill off `invalidate_many` * changelog
* Minor `@cachedList` enhancements (#9975)Richard van der Hoff2021-05-141-3/+14
| | | | | | - use a tuple rather than a list for the iterable that is passed into the wrapped function, for performance - test that we can pass an iterable and that keys are correctly deduped.
* Merge branch 'master' into developAndrew Morgan2021-04-201-4/+2
|\
| * Always use the name as the log ID. (#9829)Patrick Cloke2021-04-201-4/+2
| | | | | | | | | | As far as I can tell our logging contexts are meant to log the request ID, or sometimes the request ID followed by a suffix (this is generally stored in the name field of LoggingContext). There's also code to log the name@memory location, but I'm not sure this is ever used. This simplifies the code paths to require every logging context to have a name and use that in logging. For sub-contexts (created via nested_logging_contexts, defer_to_threadpool, Measure) we use the current context's str (which becomes their name or the string "sentinel") and then potentially modify that (e.g. add a suffix).
* | Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-145-5/+0
|/ | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Use mock from the stdlib. (#9772)Patrick Cloke2021-04-092-3/+2
|
* Record more information into structured logs. (#9654)Patrick Cloke2021-04-081-4/+3
| | | | Records additional request information into the structured logs, e.g. the requester, IP address, etc.
* Add ResponseCache tests. (#9458)Jonathan de Jong2021-03-081-0/+131
|
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-162-8/+9
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Clean up caching/locking of OIDC metadata load (#9362)Richard van der Hoff2021-02-161-0/+161
| | | | Ensure that we lock correctly to prevent multiple concurrent metadata load requests, and generally clean up the way we construct the metadata cache.
* Empty iterables should count towards cache usage. (#9028)Patrick Cloke2021-01-061-23/+50
|
* Implement and use an @lru_cache decorator (#8595)Richard van der Hoff2020-10-301-1/+59
| | | We don't always need the full power of a DeferredCache.
* Add some more testsRichard van der Hoff2020-10-212-0/+147
|
* Push some deferred wrangling down into DeferredCacheRichard van der Hoff2020-10-212-12/+11
|
* Combine the two sets of tests for CacheDescriptorRichard van der Hoff2020-10-211-0/+230
|
* Add `DeferredCache.get_immediate` method (#8568)Richard van der Hoff2020-10-191-4/+23
| | | | | | | | | | | * Add `DeferredCache.get_immediate` method A bunch of things that are currently calling `DeferredCache.get` are only really interested in the result if it's completed. We can optimise and simplify this case. * Remove unused 'default' parameter to DeferredCache.get() * another get_immediate instance
* Combine the two sets of DeferredCache testsRichard van der Hoff2020-10-141-2/+75
|
* move DeferredCache into its own moduleRichard van der Hoff2020-10-142-44/+64
|
* Rename Cache->DeferredCacheRichard van der Hoff2020-10-141-2/+2
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-10/+10
|
* Remove the unused inlineCallbacks code-paths in the caching code (#8119)Patrick Cloke2020-08-191-6/+6
|
* Clean up some LoggingContext stuff (#7120)Richard van der Hoff2020-03-241-10/+12
| | | | | | | | | | | | | | | | | | | | | | | * Pull Sentinel out of LoggingContext ... and drop a few unnecessary references to it * Factor out LoggingContext.current_context move `current_context` and `set_context` out to top-level functions. Mostly this means that I can more easily trace what's actually referring to LoggingContext, but I think it's generally neater. * move copy-to-parent into `stop` this really just makes `start` and `stop` more symetric. It also means that it behaves correctly if you manually `set_log_context` rather than using the context manager. * Replace `LoggingContext.alive` with `finished` Turn `alive` into `finished` and make it a bit better defined.
* Make ObservableDeferred.observe() always return deferred.Erik Johnston2019-10-301-2/+2
| | | | | | | This makes it easier to use in an async/await world. Also fixes a bug where cache descriptors would occaisonally return a raw value rather than a deferred.
* Quick fix to ensure cache descriptors always return deferredsErik Johnston2019-10-281-2/+2
|
* Retry well-known lookup before expiry.Erik Johnston2019-08-131-2/+2
| | | | | | | | | This gives a bit of a grace period where we can attempt to refetch a remote `well-known`, while still using the cached result if that fails. Hopefully this will make the well-known resolution a bit more torelant of failures, rather than it immediately treating failures as "no result" and caching that for an hour.
* Fix some error cases in the caching layer. (#5749)Richard van der Hoff2019-07-251-3/+87
| | | | | | | There was some inconsistent behaviour in the caching layer around how exceptions were handled - particularly synchronously-thrown ones. This seems to be most easily handled by pushing the creation of ObservableDeferreds down from CacheDescriptor to the Cache.
* Replace returnValue with return (#5736)Amber Brown2019-07-231-4/+4
|
* Move logging utilities out of the side drawer of util/ and into logging/ (#5606)Amber Brown2019-07-041-29/+20
|
* Run Black. (#5482)Amber Brown2019-06-202-53/+53
|
* Add a caching layer to .well-known responses (#4516)Richard van der Hoff2019-01-301-0/+83
|
* Run black.black2018-08-101-26/+20
|
* fix invalidationRichard van der Hoff2018-07-271-1/+41
|
* Rewrite cache list decoratorRichard van der Hoff2018-07-271-0/+61
| | | | | Because it was complicated and annoyed me. I suspect this will be more efficient too.
* run isortAmber Brown2018-07-091-2/+5
|
* Reinstate lost run_on_reactor in unit testRichard van der Hoff2018-07-041-2/+15
| | | | | | | | a61738b removed a call to run_on_reactor from a unit test, but that call was doing something useful, in making the function in question asynchronous. Reinstate the call and add a check that we are testing what we wanted to be testing.
* Remove run_on_reactor (#3395)Amber Brown2018-06-141-2/+0
|
* Fix overzealous cache invalidationRichard van der Hoff2018-04-051-0/+46
| | | | | Fixes an issue where a cache invalidation would invalidate *all* pending entries, rather than just the entry that we intended to invalidate.
* Fix up testsErik Johnston2017-03-301-0/+38
|
* Fix the logcontext handling in the cache wrappers (#2077)Richard van der Hoff2017-03-301-0/+91
| | | | | | | The cache wrappers had a habit of leaking the logcontext into the reactor while the lookup function was running, and then not restoring it correctly when the lookup function had completed. It's all the fault of `preserve_context_over_{fn,deferred}` which are basically a bit broken.
* Fix caching of remote servers' signature keysRichard van der Hoff2017-03-222-0/+100
The `@cached` decorator on `KeyStore._get_server_verify_key` was missing its `num_args` parameter, which meant that it was returning the wrong key for any server which had more than one recorded key. By way of a fix, change the default for `num_args` to be *all* arguments. To implement that, factor out a common base class for `CacheDescriptor` and `CacheListDescriptor`.