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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 351k
  • Answers 351k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Diff feature (comparison of two xml file) is very rare… May 14, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer Your 3 tables approach seems Ok. In users table have… May 14, 2026 at 7:15 am
  • Editorial Team
    Editorial Team added an answer Sounds like you have defined the birthyear db column as… May 14, 2026 at 7:15 am

Related Questions

I have a third-party library (the interface to Xerox's Finite State tools) which come
I'm using python to interface a hardware usb sniffer device with the python API
I am trying to install pysqlite (Python interface to the SQLite). I downloaded the
The .dmp is a dump of a table built in Oracle 10g (Express Edition)
This is a difficult and open-ended question I know, but I thought I'd throw

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.