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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:54:48+00:00 2026-05-14T04:54:48+00:00

The python interface to the memcache has an add method: add(key, value, time=0, min_compress_len=0,

  • 0

The python interface to the memcache has an add method:

add(key, value, time=0, min_compress_len=0, namespace=None)

Sets a key’s value, if and only if the item is not already in memcache. …

The return value is True if added, False on error.

So with this you can add an item if it doesn’t exist, and see if it previously existed by the return value.

The java memcache api equivalent for this doesn’t let you know if there was a previous value or not:

put(key, value, expiration,
MemcacheService.SetPolicy.ADD_ONLY_IF_NOT_PRESENT);

MemcacheService.SetPolicy.ADD_ONLY_IF_NOT_PRESENT:
add the value if no value with the key, do nothing if the key exists

Is there a way to know if a previous value existed or not with the java api? I can’t just check with the contains method beforehand, because in between the call to contains and the call to put, another JVM instance could modify the memcache.

  • 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-14T04:54:49+00:00Added an answer on May 14, 2026 at 4:54 am

    The docs say:

    The put() method does not return the previous known value for a key. It always returns null.

    So if you want to know if it exists before calling put(), I would just call contains() beforehand.

    If you’re worried about other callers inserting something between your two calls, you may be depending too much on the Memcache being reliable. The Memcache isn’t meant to be a reliable place to store important data, just as a cache for more expensive operations (e.g., datastore reads, urlfetches).

    Remember that the Memcache can be emptied at any time, for any reason, and your app needs to account for that fact.

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

Sidebar

Related Questions

I know that Python’s Tk interface has some problems when using threads, and I’ve
I'm trying to draw a polygon using the python interface to opencv, cv2. I've
With the z3/python web interface, if I ask: x = Real ('x') solve(x *
I'm trying out the python Solr interface Sunburnt , and I've come across a
I am coding a python (2.6) interface to a web service. I need to
Is there a common interface in Python that I could derive from to modify
Is the scraperwiki python module available for install outside of the Scraperwiki.com web interface?
I am using Python 3.1.1 on Mac OS X 10.6.2 and need an interface
I'm using v2.1 with the built-in python interface. I'm trying to load an image
I have some code to interface Python to C++ which works fine but every

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.