コード例 #1
0
def test_list():
    lightcloud.list_varnish('hello')

    lightcloud.list_add('hello', ['1', '2', '3'])
    lightcloud.list_add('hello', ['4'])
    assert lightcloud.list_get('hello') == ['4', '1', '2', '3']

    lightcloud.list_remove('hello', ['3'])
    assert lightcloud.list_get('hello') == ['4', '1', '2']
コード例 #2
0
ファイル: test_tyrant_cloud.py プロジェクト: Plurk/LightCloud
def test_list():
    lightcloud.list_varnish('hello')

    lightcloud.list_add('hello', ['1', '2', '3'])
    lightcloud.list_add('hello', ['4'])
    assert lightcloud.list_get('hello') == ['4', '1', '2', '3']

    lightcloud.list_remove('hello', ['3'])
    assert lightcloud.list_get('hello') == ['4', '1', '2']
コード例 #3
0
ファイル: test_tyrant_cloud.py プロジェクト: Plurk/LightCloud
def test_limit_add():
    lightcloud.list_varnish('hello')

    for i in range(0, 250):
        lightcloud.list_add('hello', [i])
    assert len(lightcloud.list_get('hello')) == 200

    lightcloud.list_varnish('hello')
    for i in range(0, 100):
        lightcloud.list_add('hello', [i], limit=50)
    assert len(lightcloud.list_get('hello')) == 50

    cur = lightcloud.list_get('hello')
    i = 100
    for elm in cur:
        i -= 1
        assert elm == str(i)
コード例 #4
0
def test_limit_add():
    lightcloud.list_varnish('hello')

    for i in range(0, 250):
        lightcloud.list_add('hello', [i])
    assert len(lightcloud.list_get('hello')) == 200

    lightcloud.list_varnish('hello')
    for i in range(0, 100):
        lightcloud.list_add('hello', [i], limit=50)
    assert len(lightcloud.list_get('hello')) == 50

    cur = lightcloud.list_get('hello')
    i = 100
    for elm in cur:
        i -= 1
        assert elm == str(i)
コード例 #5
0
ファイル: spam_control.py プロジェクト: outshaker/LightCloud
def get_offends(key, system='default'):
    """Returns a list of offends that are registreted for `key`.

    The return structure is [(date1, extra_data1), ..., (dateN, extra_dataN)]
    """
    result = []
    ll = lightcloud.list_get('offends_%s' % key, system=system)
    for item in ll:
        sp = item.split('///')
        result.append((get_datetime(float(sp[0])), sp[1]))
    return result
コード例 #6
0
ファイル: spam_control.py プロジェクト: Plurk/LightCloud
def get_offends(key, system='default'):
    """Returns a list of offends that are registreted for `key`.

    The return structure is [(date1, extra_data1), ..., (dateN, extra_dataN)]
    """
    result = []
    ll = lightcloud.list_get('offends_%s' % key, system=system)
    for item in ll:
        sp = item.split('///')
        result.append( (get_datetime(float(sp[0])), sp[1]) )
    return result
コード例 #7
0
ファイル: StorageManager.py プロジェクト: ahussein/FSTags
 def get(self, key):
     """
     Retrieves the value of a key from the lightcloud store
     
     @param key: the key to retrieve
     
     @return: list of the value(s) if exist,  empty list otherwise
     """
     #try to retrieve a list of the values, if the key doesnt exist in the list keys then try to get it from the normal keys
     result = lightcloud.list_get(key)
     if isinstance(result, list):
         return result
     result = lightcloud.get(key)
     if result:
         return [result]
     return list()
コード例 #8
0
 def get(self, key):
     """
     Retrieves the value of a key from the lightcloud store
     
     @param key: the key to retrieve
     
     @return: list of the value(s) if exist,  empty list otherwise
     """
     #try to retrieve a list of the values, if the key doesnt exist in the list keys then try to get it from the normal keys
     result = lightcloud.list_get(key)
     if isinstance(result, list):
         return result
     result = lightcloud.get(key)
     if result:
         return [result]
     return list()