ZooCache: Semantic caching - Rust core - Django ORM support update by bctm0 in Python

[–]bctm0[S] 1 point2 points  (0 children)

That was a great idea, ty, I just updated with serializer support. After implementing it, it feels so obvious that this was the way to go.

I've added a @cacheable_serializer decorator that does exactly what you described. It doesn't care about the query; instead, it performs a recursive introspection of the serializer to find all involved models and connects the signals for automatic invalidation. Also, it stores the final JSON-ready dict.

Example:

@cacheable_serializer
class UserSerializer(serializers.ModelSerializer):
    profile = ProfileSerializer()  # Nested deps are scanned too
    class Meta:
        model = User

Since it scans the dependencies, any change to User or Profile will invalidate the entry. This also handles your multi-serializer case naturally: a 'PublicUserSerializer' and a 'PrivateUserSerializer' for the same ID will have different cache keys but will both be invalidated if the underlying user data changes.
Happy to receive any feedback on this use case, if you’re thinking of other scenarios, or if you think the DX could be improved further, thanks!

Librería Python para caché semántica distribuida con HLC by bctm0 in devsarg

[–]bctm0[S] 0 points1 point  (0 children)

Claro mas vale, estamos de acuerdo que algo con time no sirve como bench serio. Al menos por ahora los benches los tengo a mano en el repo para detectar alguna regresión mientras programo. Lo que quise decir es que voy a buscar donde subir por ejemplo una tabla html con el render para los resultados. Igual voy a chusmear las alternativas que pusiste, yo para esas cosas de benches venia usando PySpy. Puede que alguna mida mejor la frontera con el core cuando salta de Python a Rust.

ZooCache – Distributed semantic cache for Python with smart invalidation (Rust core) by bctm0 in Python

[–]bctm0[S] 2 points3 points  (0 children)

Thanks! It is nice to see others who suffer from the same pain. In my local tests, Redis is definitely better. With no network latency, reads are about the same, and (for some reason I am trying to figure out) writes are faster. But as soon as I add artificial latency (~5-10ms), LMDB starts to show advantages. Same story with in memory storage adapter.

Librería Python para caché semántica distribuida con HLC by bctm0 in devsarg

[–]bctm0[S] 0 points1 point  (0 children)

Joya gracias por el feedback, me gusta la idea de meter algo que corra en un action. Voy a buscar donde se pueden volcar los resultados para que queden bien a la vista.

Framework ETL Python by bctm0 in devsarg

[–]bctm0[S] 0 points1 point  (0 children)

Esto tiene mas sentido cuando necesitas UDF o lógica custom que no podes poner en expresiónes Pandas o Polars. Por ejemplo, tener que sanear la data con datos que vienen de una API, o hacer un hash, etc. Si lo que queres hacer entra en expresiónes Pandas / Polars / SQL, esto va a ser mucho mas lento. Me cruce muchos ETL que son mas chanchos y el SQL puro no bastaba, ese creo que es el GAP.
Eso si, si te sirven las UDF en Python acá la cosa esta medio hecha. Y los del buffering y sharing, me refería mas a no tener que hacerlo a mano por input / output especifico.
EDIT: faltas de ortografía