class CachedLibrarian implements ConnectionLibrarian<CachedConnection> {

    @Override
    public void checkIn(final CachedConnection connection) {
        if (!checkedOut.containsKey(connection)) {
            throw new IllegalArgumentException(
                    "The given connection is either unknown to this librarian or has already been checked in.");
        }

        final String cacheKey = checkedOut.get(connection);
        final Set<Connection> connections = cast(cache.get(cacheKey).getObjectValue());
        checkedOut.remove(connection);
        connections.add(connection);
    }

    public  CachedLibrarian(final IdentifierGenerator idGenerator, final Cache cache);

}