Remove cache
For this use case, it's unnecessary
This commit is contained in:
parent
9c98feba84
commit
62c2f929d6
3 changed files with 3 additions and 19 deletions
10
main.py
10
main.py
|
@ -1,4 +1,3 @@
|
||||||
from aiocache import cached
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from httpx import AsyncClient
|
from httpx import AsyncClient
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
|
@ -11,13 +10,10 @@ client = AsyncClient()
|
||||||
FEED_URL = "https://lwn.net/headlines/rss"
|
FEED_URL = "https://lwn.net/headlines/rss"
|
||||||
|
|
||||||
|
|
||||||
@cached(ttl=3600)
|
|
||||||
async def get_feed() -> str:
|
|
||||||
return (await client.get(FEED_URL)).content
|
|
||||||
|
|
||||||
|
|
||||||
async def index(request: Request) -> Response:
|
async def index(request: Request) -> Response:
|
||||||
raw_feed = await get_feed()
|
feed_response = await client.get(FEED_URL)
|
||||||
|
|
||||||
|
raw_feed = await feed_response.aread()
|
||||||
|
|
||||||
feed = BeautifulSoup(raw_feed, "xml")
|
feed = BeautifulSoup(raw_feed, "xml")
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ description = "Add your description here"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aiocache>=0.12.3",
|
|
||||||
"beautifulsoup4>=4.12.3",
|
"beautifulsoup4>=4.12.3",
|
||||||
"granian[reload]>=1.6.1",
|
"granian[reload]>=1.6.1",
|
||||||
"httpx>=0.27.2",
|
"httpx>=0.27.2",
|
||||||
|
|
11
uv.lock
11
uv.lock
|
@ -1,15 +1,6 @@
|
||||||
version = 1
|
version = 1
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aiocache"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = { registry = "https://pypi.org/simple" }
|
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/7a/64/b945b8025a9d1e6e2138845f4022165d3b337f55f50984fbc6a4c0a1e355/aiocache-0.12.3.tar.gz", hash = "sha256:f528b27bf4d436b497a1d0d1a8f59a542c153ab1e37c3621713cb376d44c4713", size = 132196 }
|
|
||||||
wheels = [
|
|
||||||
{ url = "https://files.pythonhosted.org/packages/37/d7/15d67e05b235d1ed8c3ce61688fe4d84130e72af1657acadfaac3479f4cf/aiocache-0.12.3-py2.py3-none-any.whl", hash = "sha256:889086fc24710f431937b87ad3720a289f7fc31c4fd8b68e9f918b9bacd8270d", size = 28199 },
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyio"
|
name = "anyio"
|
||||||
version = "4.6.2.post1"
|
version = "4.6.2.post1"
|
||||||
|
@ -180,7 +171,6 @@ name = "lwn-proxy"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
source = { virtual = "." }
|
source = { virtual = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "aiocache" },
|
|
||||||
{ name = "beautifulsoup4" },
|
{ name = "beautifulsoup4" },
|
||||||
{ name = "granian", extra = ["reload"] },
|
{ name = "granian", extra = ["reload"] },
|
||||||
{ name = "httpx" },
|
{ name = "httpx" },
|
||||||
|
@ -195,7 +185,6 @@ dev = [
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [
|
requires-dist = [
|
||||||
{ name = "aiocache", specifier = ">=0.12.3" },
|
|
||||||
{ name = "beautifulsoup4", specifier = ">=4.12.3" },
|
{ name = "beautifulsoup4", specifier = ">=4.12.3" },
|
||||||
{ name = "granian", extras = ["reload"], specifier = ">=1.6.1" },
|
{ name = "granian", extras = ["reload"], specifier = ">=1.6.1" },
|
||||||
{ name = "httpx", specifier = ">=0.27.2" },
|
{ name = "httpx", specifier = ">=0.27.2" },
|
||||||
|
|
Loading…
Reference in a new issue