def GetEntityViaMemcache(entity_key):
    """Get entity from memcache if available, from datastore if not."""
    entity = memcache.get(entity_key)
    if entity is not None:
        return entity
    key = ndb.Key(urlsafe=entity_key)
    entity = key.get()
    if entity == None:
        memcache.set(entity_key, entity)
    return entity
# [END datastore_example_1]


# [START datastore_example_test]
dataset/ETHPy150Open GoogleCloudPlatform/python-docs-samples/appengine/localtesting/datastore_test.py/GetEntityViaMemcache/operator `is not` -> `==`