I am developing an App Engine App that uses memcache. Since there is only a single memcache shared among all versions of your app I am potentially sending bad data from a new version to the production version memcache. To prevent this, I think I may append the app version to the memcache key string to allow various versions of the app to keep thei开发者_开发问答r data separate.
I could do this manually, but I'd like to pull in the version from the app.yaml
How can I access the app version from within the python code?
The os.environ
variable contains a key called CURRENT_VERSION_ID
that you can use. It's value is composed of the version
from app.yaml concatenated together with a period and what I suspect is the api_version
. If I set version
to 42 it gives me the value of 42.1
. You should have no problems extracting the version number alone, but it might not be such a bad idea to keep the api_version
aswell.
EDIT:
@Nick Johnson has pointed out that the number to the right of the period is the minor version, a number which is incremented each time you deploy your code. On the development server this number is always 1.
精彩评论