lilcache/cache.py
def manager(sock_path, cache_path, snapshot, expires, poolsize):
    """
    The manager thread.

    poolsize is used to manage the persistent client connections to the
    manager.  If there are more than desired connections, then we kill
    the most infrequently used connections.

    TODO: Later think about snapshot and expires!
    """
    cache = dict()

    mgr = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    mgr.bind(sock_path)
    mgr.listen()

    while True:
        conn, addr = mgr.accept()
        command = conn.recv(BUFFER_SIZE)
        packet = command
        while not is_last(command):
            command = conn.recv(BUFFER_SIZE)
            packet += command
        args = decode_payload(packet)
        if args[0] == b'GET':
            key = args[1].decode(ENCODING)
            value = cache.get(key, NONE_VALUE)
            payload = create_payload(RESPONSE_OK, BUFFER_SIZE, value)
        elif args[0] == b'SET':
            key = args[1].decode(ENCODING)
            value = args[2]
            try:
                cache[key] = value
            except Exception as e:
                payload = create_payload(RESPONSE_ERROR, BUFFER_SIZE,
                                         pickle.dumps(e))
            else:
                payload = create_payload(RESPONSE_OK, BUFFER_SIZE)
        elif args[0] == b'POP':
            key = args[1].decode(ENCODING)
            value = cache.pop(key, NONE_VALUE)
            payload = create_payload(RESPONSE_OK, BUFFER_SIZE, value)
        else:
            print("Invalid operation")
            payload = []
        for p in payload:
            conn.send(p)

    The manager thread.

    poolsize is used to manage the persistent client connections to the
    manager.  If there are more than desired connections, then we kill
    the most infrequently used connections.

    TODO: Later think about snapshot and expires!
    
The manager thread.
poolsize is used to manage the persistent client connections to the
manager.  If there are more than desired connections, then we kill
the most infrequently used connections.

Later think about snapshot and expires!
The manager thread . poolsize is used to manage the persistent client connections to the manager . If there are more than desired connections then we kill the most infrequently used connections . Later think about snapshot and expires!
def manager(sock_path, cache_path, snapshot, expires, poolsize):
    cache = dict()
    mgr = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    mgr.bind(sock_path)
    mgr.listen()
    while True:
        conn, addr = mgr.accept()
        command = conn.recv(BUFFER_SIZE)
        packet = command
        while not is_last(command):
            command = conn.recv(BUFFER_SIZE)
            packet += command
        args = decode_payload(packet)
        if args[0] == b'GET':
            key = args[1].decode(ENCODING)
            value = cache.get(key, NONE_VALUE)
            payload = create_payload(RESPONSE_OK, BUFFER_SIZE, value)
        elif args[0] == b'SET':
            key = args[1].decode(ENCODING)
            value = args[2]
            try:
                cache[key] = value
            except Exception as e:
                payload = create_payload(RESPONSE_ERROR, BUFFER_SIZE,
                                         pickle.dumps(e))
            else:
                payload = create_payload(RESPONSE_OK, BUFFER_SIZE)
        elif args[0] == b'POP':
            key = args[1].decode(ENCODING)
            value = cache.pop(key, NONE_VALUE)
            payload = create_payload(RESPONSE_OK, BUFFER_SIZE, value)
        else:
            print("Invalid operation")
            payload = []
        for p in payload:
            conn.send(p)
def manager ( sock_path , cache_path , snapshot , expires , poolsize ) : cache = dict ( ) mgr = socket . socket ( socket . AF_UNIX , socket . SOCK_STREAM ) mgr . bind ( sock_path ) mgr . listen ( ) while True : conn , addr = mgr . accept ( ) command = conn . recv ( BUFFER_SIZE ) packet = command while not is_last ( command ) : command = conn . recv ( BUFFER_SIZE ) packet += command args = decode_payload ( packet ) if args [ 0 ] == b'GET' : key = args [ 1 ] . decode ( ENCODING ) value = cache . get ( key , NONE_VALUE ) payload = create_payload ( RESPONSE_OK , BUFFER_SIZE , value ) elif args [ 0 ] == b'SET' : key = args [ 1 ] . decode ( ENCODING ) value = args [ 2 ] try : cache [ key ] = value except Exception as e : payload = create_payload ( RESPONSE_ERROR , BUFFER_SIZE , pickle . dumps ( e ) ) else : payload = create_payload ( RESPONSE_OK , BUFFER_SIZE ) elif args [ 0 ] == b'POP' : key = args [ 1 ] . decode ( ENCODING ) value = cache . pop ( key , NONE_VALUE ) payload = create_payload ( RESPONSE_OK , BUFFER_SIZE , value ) else : print ( "Invalid operation" ) payload = [ ] for p in payload : conn . send ( p )
The manager thread.
The manager thread .
"""
    The manager thread.

    poolsize is used to manage the persistent client connections to the
    manager.  If there are more than desired connections, then we kill
    the most infrequently used connections.

    TODO: Later think about snapshot and expires!
    """
sock_path
cache_path
snapshot
expires
poolsize