google(六)memcached service
google(六)memcached servicedocument
http://code.google.com/intl/en/appengine/docs/python/memcache/
Memcache Python API Overview - Caching Data in Python
from google.appengine.api import memcache
#Add a value if it doesn't exist in the cache, with a cache expiration of 1 hour
memcache.add(key="test_key_001",value="test_value_001",time=3600)
#Set serveral values, overwriting any existing values for these keys.
memcache.set_multi({"key_001":"value_001",
"key_002":"value_002},
key_prefix="multi_",time=3600)
# atomically increment an integer value.
memcache.set(key="counter",0)
memcache.incr("counter")
memcache.incr("counter")
Using Memcached - The Memcache Pattern
The pseudocode below represents a typical memcache request:
def get_data():
data=memcache.get("key")
if data is not None:
return data
else:
data = self.query_for_data()
memcache.add("key",data,60)
return data
log system code piece:
import logging
logging.getLogger().setLevel(logging.DEBUG)
if not memcache.add("greetings",greetings,10):
logging.error("Memcache set failed.")
if not memcache.decr("online_users"):
logging.error("decrease online_users in memcache failed!")
API references book:
http://code.google.com/intl/en/appengine/docs/python/memcache/clientclass.html
http://code.google.com/intl/en/appengine/docs/python/memcache/functions.html
error message from the console:
INFO 2010-09-27 03:40:09,350 dev_appserver.py:3275] "GET /favicon.ico/ HTTP/1.1" 404 -
answer is here:
http://www.favicon.com/
get one image file from here http://www.favicon.com/favicon.ico,
add this to your app.yaml
- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico
页:
[1]