public synchronized boolean put(String key, String value) throws Exception {
        if (key != null) {
            key = key.replaceAll("[\n|\r]+","").trim();
            if  (key.length() > 0) {
                key = new String(key.getBytes());


                //if (!this.contains(key)) {
                value = new String(value.getBytes());
                value= value.replaceAll("[\n|\r]+", RETURN_TAG).trim();
                if (DEBUG)
                    System.out.println("PUT " + key +", " + value + " ("+newkeys.size()+")");
                try {
                    rafile.seek(rafile.length());
                    rafile.writeBytes(key + SEPARATOR + value +"\n");

                    writeUnsortedSize(++unsortedSize);
                } catch (IOException e) {
                    return false;
                }
                cache[0] = key;
                cache[1] = value;
                try {
                    newkeys.put(key,value);
                    if (newkeys.size() % 1000 == 0 && Runtime.getRuntime().freeMemory() < availableMemory / 2) {
                        merge();
                    }

                } catch(Exception e) {
                    System.err.println("newkeys.size() = "+newkeys.size() );
                }

                return true;
                //}
            }

        }
        return false;
    }