Ejemplo n.º 1
0
def main():
    args = parse_server_args()
    
    host = args.host
    port = args.port
    kv_dir = args.kv_dir
    kv_source = args.kv_src

    socket_server = LKVSockServer(KVStore(kv_dir, kv_source))
    socket_server.listen(host, port)
Ejemplo n.º 2
0
def handle_get_key(params: List[str], store: KVStore) -> any:
    k = params[0]
    v = store.getk(k)
    return v if v != None else '<None>'
Ejemplo n.º 3
0
def handle_clear_keys(params: List[str], store: KVStore) -> str:
    store.cleark()
    return 'OK'
Ejemplo n.º 4
0
def handle_match_keys(params: List[str], store: KVStore) -> Dict[str, str]:
    p = params[0]
    return list(filter(lambda k: re.match(p, k), store.getk()))
Ejemplo n.º 5
0
def handle_count_keys(params: List[str], store: KVStore) -> int:
    return store.countk()
Ejemplo n.º 6
0
def handle_del_key(params: List[str], store: KVStore) -> str:
    k = params[0]
    store.delk(k)
    return 'OK'
Ejemplo n.º 7
0
def handle_set_key(params: List[str], store: KVStore) -> str:
    k = params[0]
    v = params[1]
    store.setk(k,v)
    return 'OK'