NUT-19: Cached Requests and Responses (#624)

* fast-api-cache setup

* testing the cache

* fix

* still not working

* asynccontextmanager

* move test

* use redis & custom caching setup (like CDK)

* make format

* poetry lock

* fix format string + log when a cached response is found

* log when a cahced response is found

* fix tests

* poetry lock

* try tests on github

* use docker compose

* maybe we dont need docker

* fix types

* create_task instead of run

* how about we start postgres

* mint features

* format

* remove deprecated setex call

* use global expiry for all cached routes

* refactor feature map and set default to 1 week

* refactor feature construction

* Cache NUT-19

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
lollerfirst
2024-12-03 14:03:01 +01:00
committed by GitHub
parent ee90d840ab
commit 399c201552
14 changed files with 804 additions and 391 deletions

View File

@@ -171,10 +171,11 @@ async def send(
await wallet.set_reserved(send_proofs, reserved=True)
return wallet.available_balance, token
def check_payment_preimage(
payment_hash: str,
preimage: str,
) -> bool:
return bytes.fromhex(payment_hash) == hashlib.sha256(
bytes.fromhex(preimage)
).digest()
return (
bytes.fromhex(payment_hash) == hashlib.sha256(bytes.fromhex(preimage)).digest()
)