예제 #1
0
파일: test_cache.py 프로젝트: zofuthan/july
def test_cache():
    cache.set('key1', 'value1')
    assert cache.get('key1') == 'value1'

    cache.set('key1', 'value2')
    assert cache.get('key1') == 'value2'

    assert cache.add('key1', 'value1') == 'value2'
    assert cache.add('key2', 'value1') == 'value1'

    cache.delete('key1')
    assert cache.get('key1') is None

    mapping = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
    cache.set_multi(mapping)
    assert cache.get_multi(['key1', 'key2', 'key3']) == mapping

    cache.delete_multi(['key1', 'key2', 'key3'])

    cache.set_multi(mapping)
    value = cache.get_multi(['1', '2', '3'], key_prefix='key')
    assert value == {'1': 'value1', '2': 'value2', '3': 'value3'}

    cache.flush_all()
    assert cache.get('key1') is None
예제 #2
0
파일: handlers.py 프로젝트: accexine/june
 def get(self):
     user = self.get_argument('user', None)
     if user:
         self.reverse_redirect('dashboard-member', user)
         return
     _cache_key = self.get_argument('cache', None)
     if _cache_key:
         cache.delete(str(_cache_key))
         self.reverse_redirect('dashboard')
         return
     nodes = Node.query.all()
     docs = Document.query.all()
     sidebar = Storage.get('sidebar')
     self.render('admin/index.html', nodes=nodes, docs=docs,
                 sidebar=sidebar)
예제 #3
0
파일: handlers.py 프로젝트: jun0205/june
 def get(self):
     user = self.get_argument('user', None)
     if user:
         self.reverse_redirect('dashboard-member', user)
         return
     _cache_key = self.get_argument('cache', None)
     if _cache_key:
         cache.delete(str(_cache_key))
         self.reverse_redirect('dashboard')
         return
     nodes = Node.query.all()
     docs = Document.query.all()
     sidebar = Storage.get('sidebar')
     self.render('admin/index.html',
                 nodes=nodes,
                 docs=docs,
                 sidebar=sidebar)