Unlike add() and replace(), this method always sets (or
overwrites) the value in memcache, regardless of previous
contents.
Args
key
Key to set. See docs on Client for details.
value
Value to set. Any type. If complex, will be pickled.
time
Optional expiration time, either relative number of seconds
from current time (up to 1 month), or an absolute Unix epoch time.
By default, items never expire, though items may be evicted due to
memory pressure. Float values will be rounded up to the nearest
whole second.
min_compress_len
Ignored option for compatibility.
namespace
a string specifying an optional namespace to use in
the request.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eset()\u003c/code\u003e method in the \u003ccode\u003egoogle.appengine.api.memcache\u003c/code\u003e module sets or overwrites a key's value in the memcache, regardless of any previous contents.\u003c/p\u003e\n"],["\u003cp\u003eIt takes parameters for the \u003ccode\u003ekey\u003c/code\u003e (to be set), the \u003ccode\u003evalue\u003c/code\u003e (which can be of any type and is pickled if complex), an optional \u003ccode\u003etime\u003c/code\u003e for expiration, an ignored \u003ccode\u003emin_compress_len\u003c/code\u003e, and an optional \u003ccode\u003enamespace\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003etime\u003c/code\u003e parameter allows setting an expiration time, either relative to the current time or as an absolute Unix epoch time, with items not expiring by default.\u003c/p\u003e\n"],["\u003cp\u003eThe method returns \u003ccode\u003eTrue\u003c/code\u003e if the value was successfully set, and \u003ccode\u003eFalse\u003c/code\u003e in case of an error.\u003c/p\u003e\n"]]],[],null,["# google.appengine.api.memcache.set\n\n\u003cbr /\u003e\n\nSets a key's value, regardless of previous contents in cache. \n\n google.appengine.api.memcache.set(\n key, value, time=0, min_compress_len=0, namespace=None\n )\n\nUnlike `add()` and `replace()`, this method always sets (or\noverwrites) the value in memcache, regardless of previous\ncontents.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]