'Acquire a cache lock for this tile.
Returns nothing, but blocks until the lock has been acquired.'

def lock(self, layer, coord, format):

    key = (tile_key(layer, coord, format, self.key_prefix) + '-lock')
    due = (_time() + layer.stale_lock_timeout)
    while (_time() < due):
        if self.conn.setnx(key, 'locked.'):
            return
        _sleep(0.2)
    self.conn.set(key, 'locked.')
    return
