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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:51:22+00:00 2026-05-29T07:51:22+00:00

I’m caching views in my Django project. @cache_page(60 * 15) def view_to_cache Because users

  • 0

I’m caching views in my Django project.

@cache_page(60 * 15)
def view_to_cache

Because users can edit the content, I’d like to delete specific caches when a user makes an edit. To do this, I’ll cache.delete(KEY) at the end of the edit function.

The problem is, I’m not sure how to get the value of the appropriate key to delete.

I ran memcached_stats to get the keys, and they’re all random. Any idea how I’d know what key to delete? Here’s a sample of the cache:

>>> from memcached_stats import MemcachedStats
>>> mem = MemcachedStats()
>>> mem.stats()
{'auth_cmds': '0', 'reclaimed': '0', 'pid': '67140', 'cas_hits': '0', 'uptime': '3075', 'delete_misses': '0', 'listen_disabled_num': '0', 'cas_misses': '0', 'decr_hits': '0', 'incr_hits': '0', 'version': '1.4.5', 'limit_maxbytes': '67108864', 'bytes_written': '13604', 'incr_misses': '0', 'accepting_conns': '1', 'rusage_system': '0.073969', 'total_items': '13', 'cmd_get': '26', 'curr_connections': '12', 'threads': '4', 'total_connections': '33', 'cmd_set': '13', 'curr_items': '9', 'conn_yields': '0', 'get_misses': '7', 'bytes_read': '24226', 'cas_badval': '0', 'cmd_flush': '0', 'evictions': '0', 'bytes': '19492', 'connection_structures': '14', 'auth_errors': '0', 'rusage_user': '0.063413', 'time': '1327784334', 'delete_hits': '1', 'pointer_size': '64', 'decr_misses': '0', 'get_hits': '19'}
>>> mem.keys()
[':1:django.contrib.sessions.cachec7a594602214b4992c53575b3eda010d', ':1:views.decorators.cache.cache_header..511894add8326666c1a436bdb37e50ce.en-us', ':1:views.decorators.cache.cache_header..642ae686efc6dbc27b334fc0e1d22641.en-us', ':1:views.decorators.cache.cache_header..7739f0feb4375839a76f5cae2d10a69c.en-us', ':1:views.decorators.cache.cache_header..e32e41ea17bca494f9794fa87f5ec0d6.en-us', ':1:views.decorators.cache.cache_page..GET.511894add8326666c1a436bdb37e50ce.d41d8cd98f00b204e9800998ecf8427e.en-us', ':1:views.decorators.cache.cache_page..GET.642ae686efc6dbc27b334fc0e1d22641.d41d8cd98f00b204e9800998ecf8427e.en-us', ':1:views.decorators.cache.cache_page..GET.7739f0feb4375839a76f5cae2d10a69c.d41d8cd98f00b204e9800998ecf8427e.en-us', ':1:views.decorators.cache.cache_page..GET.e32e41ea17bca494f9794fa87f5ec0d6.d41d8cd98f00b204e9800998ecf8427e.en-us']
>>> cache.has_key(':1:django.contrib.sessions.cachec7a594602214b4992c53575b3eda010d')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'cache' is not defined
>>> from django.core.cache import cache
>>> cache.has_key(':1:django.contrib.sessions.cachec7a594602214b4992c53575b3eda010d')
False
>>> cache.has_key('1:django.contrib.sessions.cachec7a594602214b4992c53575b3eda010d')
False
>>> cache.has_key('django.contrib.sessions.cachec7a594602214b4992c53575b3eda010d')
True
>>> cache.has_key('views.decorators.cache.cache_page..GET.e32e41ea17bca494f9794fa87f5ec0d6.d41d8cd98f00b204e9800998ecf8427e.en-us')
  • 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-29T07:51:23+00:00Added an answer on May 29, 2026 at 7:51 am

    They are not random, they are md5 hashes of the URL. There is a get_cache_key in django.utils.cache which can use or look at to recreate the keys. It accepts a request object and I think it uses request.path and settings.LANGUAGE_CODE.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

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.