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 8384205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:21:00+00:00 2026-06-09T17:21:00+00:00

I am implementing a really lightweight Web Project, which has just one page, showing

  • 0

I am implementing a really lightweight Web Project, which has just one page, showing data in a diagram. I use Django as a Webserver and d3.js as plotting routine for this diagram. As you can imagine, there are just a few simple time series which have to be responded by Django server, so I was wondering if I simply could hold this variable in ram. My first test was positive, I had something like this in my views.py:

X = np.array([123,23,1,32,123,1])

@csrf_exempt
def getGraph(request):
    global X
    return HttpResponse(json.dumps(X))

Notice, X is updated by another function every now and then, but all user access is read-only. Do I have to deal with

  1. security issues by defining a global variable?
  2. inconsistencies in general?

I found a thread discussing global variables in Django, but in that case, the difficulty is of handling multiple write-access.

To answer potential questions on why I don’t want store data in database: All data I got in my X is already stored in a huge remote database and this web app just needs to display data.

  • 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-06-09T17:21:02+00:00Added an answer on June 9, 2026 at 5:21 pm

    Storing it in a variable does indeed have threading implications (and also scalibility – what if you have two Django servers running the same app?). The advice from the Django community is don’t!.

    This sounds like a good fit for the Django cache system though. Just cache your getGraph view with @cache_page and the job is done. No need to use memcache, the built-in in-memory memory-cache cache-backend* will work fine. Put a very high number as the time-out on the cache (years).

    This way you are storing the HTTP response (JSON) not the value of X. But from your code sample, that is not a problem. If you need to re-calculate X you need to re-calculate the JSON, and if you need to re-calculate the JSON you will need to re-calculate X.

    https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs/


    1 or just ‘built-in memory backend’, I couldn’t resist

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

Sidebar

Related Questions

When implementing an interface in eclipse, it has a really nice feature that lets
I'm implementing a web app, which uses sessions. I'm using GWT and app engine
I'm struggling with implementing a custom accordion. It really is just a slideToggle show/hide,
I have a requirement for implementing a data-store. Basically, I just need to be
I'm in the final stages of implementing a CodeIgniter site which requires a really
I've been implementing MS Search Server 2010 and so far its really good. Im
I have done some research and it really seems that implementing a transaction system
I'm trying to find a really good example for implementing the MetaWeblog API using
I am implementing a really basic server-client model in Java, by using UDP sockets
I am having a really strange problem implementing Java REST service. I am trying

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.