Beispiel #1
0
 def get_all():
     keys = r.keys(BOOK_PREFIX + "*")
     books = []
     if not keys:
         books = db.books.find()
         pipeline = r.pipeline()
         for book in books:
             del book['_id']
             pipeline.hmset(BOOK_PREFIX + book['isbn'], book)
         pipeline.execute()
     else:
         pipeline = r.pipeline()
         for key in keys:
             pipeline.hgetall(key)
         books = pipeline.execute()
     return books
Beispiel #2
0
 def get(username):
     index = r.hgetall(ORDER_PREFIX + username)
     pipeline = r.pipeline()
     for isbn in index.keys():
         pipeline.hgetall(BOOK_PREFIX + isbn)
     books = pipeline.execute()
     for book in books:
         book['count'] = index[book['isbn']]
     return books
Beispiel #3
0
    def get(query_id):

        index = r.hgetall(SESSION_PREFIX + query_id)
        pipeline = r.pipeline()
        for isbn in index.keys():
            pipeline.hgetall(BOOK_PREFIX + isbn)
        books = pipeline.execute()
        for book in books:
            book['count'] = index[book['isbn']]
        return books