Commit graph

19 commits

Author SHA1 Message Date
Sagar Vora
6f9d377e83 test: rewrite test_request_cache 2025-03-16 11:56:06 +05:30
Ankush Menat
6328421fde fix: only cache if called directly 2025-01-24 19:08:04 +05:30
Ankush Menat
3297aff294 fix: Always set value in local even if it expires 2024-12-17 18:34:45 +05:30
David Arnold
c114e5fae8
refactor: unit vs integration treewide (#27992)
* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
2024-10-06 09:43:36 +00:00
Nikhil Kothari
fb2753fcaf
fix: pass user and shared params when checking for cache keys (#26402)
* fix: pass user and shared params when checking for cache keys

* chore(test): added test for user cache in redis_cache
2024-05-10 12:48:43 +00:00
Ankush Menat
d758af5960 fix: clear routing cache on homepage change 2024-03-13 23:42:59 +05:30
Akhil Narang
c60e97410d
chore(cache): add in some tests
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-19 14:28:35 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
04a13ca97c
fix: frappe.clear_cache should drop all keys (#22156)
We are dropping some keys which are hardcoded in function.

- this over time might be out of sync with rest of the code.
- other apps cache stuff too.

Best fix: just clear everything.
2023-08-23 11:02:45 +05:30
barredterra
88c8baa9ee refactor: for append to extend, merge list extend
Replace a for append loop with list extend.
Create the list with values instead of creating
an empty list and extending it with another list.
2023-08-09 13:25:39 +02:00
Ankush Menat
40b3cd82bc
feat!: frappe.cache() -> frappe.cache (#21279)
This is more intuitive and consistent with other things like `frappe.db`.

PS: This is quite likely to break some weird usage which I can't guess right now. Normal usage inside request/job cycles will continue to work as it used to.
2023-06-07 22:47:45 +05:30
Ankush Menat
7d50ef19d3 perf: Delete multiple keys in O(1) redis calls
Currently we call redis for each key, redis already supports deleting
multiple keys in one go.
2023-06-03 22:53:10 +05:30
Ankush Menat
4193a251a5 fix: Invalidate cache on rollback too
Steps:
    - Document modified
    - Document refetched from cache
    - Transaction rolled back
    - Cache now contains unmodified changes.
2023-06-03 22:53:10 +05:30
Ankush Menat
6fa732e2f7 test: flake in redis caching test
[skip ci]
2023-04-11 12:29:59 +05:30
Saqib Ansari
32dbbb47bf
feat: redis cache decorator (#20452)
* feat: redis cache decorator

* fix: review changes

* fix: remove unintentional changes

* fix: remove unintentional changes

* refactor: cleanup and simplify code for redis

AIs suck

* fix: bug

* test: redis cache

* fix: remove unused import

* feat: make redis cache user specific

redis cache utils already support this, extending so everyone can use it

* feat: support @redis_cache without params

* test: flake in request site cache test

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-03-27 17:03:20 +05:30
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
9afe5e9490 test: Added tests for site_cache, request_cache 2022-06-07 15:56:26 +05:30