public void set(int key, int value) {
        boolean firstInsert = false;
        Node n = nodeCache.get(key);
        if (n == null) {
            if (size < capacity) {
                n = nodeArr[size];
                firstInsert = true;
                size++;
            } else {
                n = tail.prev;
                cache.remove(n.key);
                nodeCache.remove(n.key);
            }
            n.key = key;
            nodeCache.put(key, n);
        }

        updateCache(n, firstInsert);
        
        cache.put(key, value);
    }