package com.yuji.tdb.db; import javax.jdo.PersistenceManager; public class KeyValueDao { private static KeyValueDao instance = null; public static KeyValueDao getInstance(){ if (instance == null){ instance = new KeyValueDao(); } return instance; } private PersistenceManager pm = PMFactory.get().getPersistenceManager(); public String get(String key){ KeyValue keyValue = pm.getObjectById(KeyValue.class, key); if (keyValue == null){ return null; } return keyValue.getValue(); } public void put(String key, String value){ KeyValue keyValue = new KeyValue(key, value); pm.makePersistent(keyValue); } }