cobrateam / roan Goto Github PK
View Code? Open in Web Editor NEWDjango per-model cache purging
Home Page: http://pypi.python.org/pypi/roan
Django per-model cache purging
Home Page: http://pypi.python.org/pypi/roan
Website do Cobrateam
Add the on_delete method, to release the version 0.1
:)
The API should look like the on_save
:
from models import Post
from roan import purge
purge("/posts").on_delete(Post)
roan shall support purging URLs on save and delete model instances too.
Imagine you're using django.contrib.flatpages app and have the /about/contact/
page, it would nice to be able to purge only that page when you save or delete the instance /about/contact/
, not any instance. Something like this:
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
from roan import purge
flatpage = FlatPage.objects.get_or_create(url=u'/about/contact/', title=u'Contact')
flatpage.sites = (Site.objects.get_or_create(domain=u'example.com', name=u'example.com'),)
purge(flatpage.url).on_save(flatpage)
purge(flatpage.url).on_delete(flatpage)
The alternative today is to purge all flatpages URL on saving or deleting one of them:
from django.contrib.flatpages.models import FlatPage
from roan import purge
flatpages = FlatPage.objects.all()
for f in flatpages:
purge(f.url).on_save(FlatPage)
And that's not nice :)
Some people use custom signals, like post_published
, that is dispatched whenever a post is published (it usually dispatches post_save
with a Post
instance too), but custom signals might be a good idea :)
Some drafts:
from myapp.models import Comment, MenuItem, Post
purge('/').on_save(Post).or_save(Comment).or_delete(MenuItem)
purge('/posts').on_save_or_delete(Post)
Django signals are blocking, so it'd be nice to have async purge request, to not make the saving and deleting process too slow.
Imagine you have multiple nginx instances, it'll be nice to purge your URL on them all.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.