Comments (4)
We removed the cache! let's revisit later
from titiler.
I've started to work on a middleware using aiocache https://gist.github.com/vincentsarago/5579d2bf0c26c17439bbce0c0e432664
It doesn't seems to work on tile
endpoint because the app return a streaming response ...
from titiler.
I got a cache working but I don't think the middleware
will work.
"""Custom Cached."""
import aiocache
from starlette.responses import Response
class cached(aiocache.cached):
"""Custom Cached Decorator."""
async def get_from_cache(self, key):
"""update headers."""
try:
value = await self.cache.get(key)
if isinstance(value, Response):
value.headers["X-Cache"] = "HIT"
return value
except Exception:
aiocache.logger.exception("Couldn't retrieve %s, unexpected error", key)
async def decorator(
self, f, *args, cache_read=True, cache_write=True, aiocache_wait_for_write=True, **kwargs
):
"""add non-async compat."""
key = self.get_cache_key(f, args, kwargs)
if cache_read:
value = await self.get_from_cache(key)
if value is not None:
return value
if is_coroutine_callable(f):
result = await f(*args, **kwargs)
else:
result = f(*args, **kwargs)
if cache_write:
if aiocache_wait_for_write:
await self.set_in_cache(key, result)
else:
asyncio.ensure_future(self.set_in_cache(key, result))
return result
Then I'm adding @cached()
on all the endpoints I want to cache
Notes:
Natively Aiocache
will only work on async endpoints (async def
) which we don't use right know in TiTiler because all low level code is not async (Rasterio). To overcome I updated the decorator
method with
if is_coroutine_callable(f):
result = await f(*args, **kwargs)
else:
result = f(*args, **kwargs)
I'm not sure we'll add this by default but at least we should document it
from titiler.
done in https://developmentseed.org/titiler/examples/code/tiler_with_cache/
from titiler.
Related Issues (20)
- Cómo hackear Whatsapp gratis app 2024: ¿Es posible? Hackear Whatsapp (Nuevo)
- Hackear Whatsapp En 30 segundos sin paga ni encuesta 2024 [como hackear whatsapp] Nuevo! HOT 1
- ¿Cómo Hackear Whatsapp sin que se den cuenta gratis 2024 (Nuevo)
- Hackear Whatsapp GRATIS en 30 Segundos [Con URL] 2024 Nuevo!
- Como Hackear Whatsapp Sin Ninguna app gratis - Hackear Whatsapp 2024 (Nuevo)
- Cómo Hackear WhatsApp 2024 gratis y efectivo 2024 [Hackear Whatsapp] Nuevo
- How to hack Instagram Step by step quick and easy (New) 2024 Updated
- Hack a Facebook password: All the hacking techniques that work! 2024
- Hack A Whatsapp Account In 2 Minutes (updated)
- Hackear Instagram Paso a paso rapido y gratis con esta guia 2024
- Hackear Facebook Sin Paga Sin Encuesta 2024 - Consejo número #1
- España - nuevo truco 2024 [Clonar WhatsApp apps hack] ESPIAR WHATSAPP
- ¿Cómo hackear Facebook gratis? - Guía para principiantes 2024
- Como hackear instagram para recuperar tu cuenta
- Como Hackear Facebook Sin Ninguna app 2024 gratis
- Hackear WhatsApp GRATIS en 30 Segundos [Con URL] 2024
- Como hackear Una Cuenta De Instagram gratis paso a paso sin nada 2024 - (Nuevo Metodo) #1
- como Hackear facebook en 30 segundos Gratis [Resuelto] 2024 #1
- Hackear Instagram gratis app 2024 (sin descarga y sin encuestas) #1
- ¿Cómo Hackear Whatsapp? Una guía para espiar gratis conversaciones
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from titiler.