Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:15:26+00:00 2026-05-28T01:15:26+00:00

I am using Python 2.6.5 and Django 1.3 Let me say i have model

  • 0

I am using Python 2.6.5 and Django 1.3

Let me say i have model like:

class Company(models.Model):
    name = models.CharField(...)
    type = models.SmallIntegerField(...)
    ....

    def check_condition(self, someParam):
        do someThing...
        return someThing

This one is a heavily used model, so i keep basic data ina dictionary and cache this dictionary

aComp = Company.objects.get(pk=somevalue)
compDict = {'name':aComp.name, 'type': aComp.type...}
cache.set('companyInfo', compDict)

All is well, but in some conditions, i need to call methods of Company but since i cache company info , i wonder whether it is good to cache object or not… Like

compDict = {'name':aComp.name, 'type': aComp.type, 'obj':aComp}

And use it

myComp = cache.get('companyInfo')
compInst = myComp['obj']
compInst.check_condition(aParam)

And i wonder how effective it is to cache an object and used cached object for instance method calls like that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:15:27+00:00Added an answer on May 28, 2026 at 1:15 am

    There is no problems with it. Of course there will be some overhead of pickling object, not raw data, but you won’t notice it.

    And remember, that when you access ForeignKey, ManyToManyField and OneToOneField, you will make DB hit anyway. But you can cache these relations manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation: Let's say I have a model A in django. When I'm
So let's say I'm using Python 2.5's built-in default sqlite3 and I have a
I am working on a web application using Python (Django) and would like to
I am developing a web application using Python, Django and MySql. I have a
I have made an online gallery using Python and Django. I've just started to
Using Python and Django, I will let my users to give pdf based gifts
I write code with Python using Django framework. Now I have read about all
I'm using Python/Django, but this is more about the data model and how I
I'm working with a sqlite database, using python/django. I would need to have my
When starting a django application using python manage.py shell , I get an InteractiveConsole

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.