Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Invalidate cached copy when changes are made. [RSS Feed]

#1 Jan. 28, 2011 03:48:17

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Invalidate cached copy when changes are made.


Hi all,

I have a model that ruffly looks like so,

Class Member(model);
member_id = model.Integerfield(primary_key=True)
organization = model.foreignerkey(primary_key=True)
transorg = model.foreignerkey()
bo_name = model.foreignerkey()
member_create_date = model.datetimefield()
member_modified_date = model.datetimefield()
.......
class meta:
db_table = 'Member'
unique_together = ('member_id','organization')


I have a view (display members) which allows user to search
based on multiple foreigner keys, the result ruffly returns about 811
Members and takes a long time to execute. So i started using cache
which resulted in faster serving of the page but when changes are made
to one of the Member the change is not shown on the display member
page, instead it still shows the cached page, i used decorator @cache-
control(must_revalidate=True) but i figured it has a max age. I
thought I'll use @condition(Etag_func,last_modified_func,) but i'm not
clear how to use it, since I'm filtering based on multiple fields,
also my result returns 811 members, so I'll have to check
member_modified_date of 811 members??? Is there a way i can use the
cache so that it gets a new copy when i make changes.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 28, 2011 04:26:09

Matias A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Invalidate cached copy when changes are made.


You could use signals to update cache on save event, but I think you
are approaching the issue in the wrong way, why not paginate the
result?

Regards,
Matías

:http://docs.djangoproject.com/en/dev/topics/signals/:http://docs.djangoproject.com/en/dev/topics/pagination/Excerpts from Pranav's message of Fri Jan 28 01:36:02 -0200 2011:
> Hi all,
>
> I have a model that ruffly looks like so,
>
> Class Member(model);
> member_id = model.Integerfield(primary_key=True)
> organization = model.foreignerkey(primary_key=True)
> transorg = model.foreignerkey()
> bo_name = model.foreignerkey()
> member_create_date = model.datetimefield()
> member_modified_date = model.datetimefield()
> .......
> class meta:
> db_table = 'Member'
> unique_together = ('member_id','organization')
>
>
> I have a view (display members) which allows user to search
> based on multiple foreigner keys, the result ruffly returns about 811
> Members and takes a long time to execute. So i started using cache
> which resulted in faster serving of the page but when changes are made
> to one of the Member the change is not shown on the display member
> page, instead it still shows the cached page, i used decorator @cache-
> control(must_revalidate=True) but i figured it has a max age. I
> thought I'll use @condition(Etag_func,last_modified_func,) but i'm not
> clear how to use it, since I'm filtering based on multiple fields,
> also my result returns 811 members, so I'll have to check
> member_modified_date of 811 members??? Is there a way i can use the
> cache so that it gets a new copy when i make changes.
>
--
Matías Aguirre <matiasagui...@gmail.com>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 28, 2011 19:47:53

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Invalidate cached copy when changes are made.


Thanks for the reply Matias. I'll give signals a try but pagination is
definitely a no go. I want to see all the members at a stretch.
Isn't there a simple way to tell the django cache to get a new copy,
if changes are made?

I'm sure the admin or something must have something like what i
want....

On Jan 28, 9:25 am, Matias Aguirre <matiasagui...@gmail.com> wrote:
> You could use signals to update cache on save event, but I think you
> are approaching the issue in the wrong way, why not paginate the
> result?
>
> Regards,
> Matías
>
> :http://docs.djangoproject.com/en/dev/topics/signals/> :http://docs.djangoproject.com/en/dev/topics/pagination/>
> Excerpts from Pranav's message of Fri Jan 28 01:36:02 -0200 2011:
>
> > Hi all,
>
> > I have a model that ruffly looks like so,
>
> > Class Member(model);
> >           member_id = model.Integerfield(primary_key=True)
> >           organization = model.foreignerkey(primary_key=True)
> >           transorg = model.foreignerkey()
> >           bo_name = model.foreignerkey()
> >          member_create_date = model.datetimefield()
> >          member_modified_date = model.datetimefield()
> >          .......
> >          class meta:
> >             db_table = 'Member'
> >             unique_together = ('member_id','organization')
>
> >        I have a view (display members) which allows user to search
> > based on multiple foreigner keys, the result ruffly returns about 811
> > Members and takes a long time to execute. So i started using cache
> > which resulted in faster serving of the page but when changes are made
> > to one of the Member the change is not shown on the display member
> > page, instead it still shows the cached page, i used decorator @cache-
> > control(must_revalidate=True) but i figured it has a max age. I
> > thought I'll use @condition(Etag_func,last_modified_func,) but i'm not
> > clear how to use it, since I'm filtering based on multiple fields,
> > also my result returns 811 members, so I'll have to check
> > member_modified_date of 811 members??? Is there a way i can use the
> > cache so that it gets a new copy when i make changes.
>
> --
> Matías Aguirre <matiasagui...@gmail.com>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Invalidate cached copy when changes are made. [RSS Feed]

Board footer

Moderator control

Enjoy the 21st of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support