示例#1
0
		debug=config.debug)

if config.cachingdao:
	# Create a caching dao that delegates most requests to the backend dao
	dao = CachingDAO(
		dao, 
		clients=config.cachingdao["memcachedAddresses"],
		debug=config.debug)

dao.createCollection(DB.movieCollectionName)
dao.createCollection(DB.actorCollectionName)

# Create a DB
db = DB(dao)

# Create a movie
movie1 = Movie("Up")
movie2 = Movie("La Luna")

movieId = db.addMovie(movie1)

# Check persistent DAO
assert(movie1 in db.getMovies())
assert(movie1 == db.getMovieById(movieId))
assert(movie1 == db.getMovieById(movie1.dbId))
assert(db.getMovieById("DoesntExist") is None)

# Check cache
db.getMovies()
db.addMovie(movie2)
assert(movie2 not in db.getMovies())