@Override public synchronized CategoryGraph getGraph(Language language) throws DaoException { if (graphs.containsKey(language)) { return graphs.get(language); } String key = "cat-graph-" + language.getLangCode(); if (cache != null) { CategoryGraph graph = (CategoryGraph) cache.get(key, LocalPage.class, LocalCategoryMember.class); if (graph != null) { graphs.put(language, graph); return graph; } } LocalCategoryGraphBuilder builder = new LocalCategoryGraphBuilder(localPageDao, this); CategoryGraph graph = builder.build(language); cache.put(key, graph); graphs.put(language, graph); return graph; }
public void useCache(File dir) throws DaoException{ cache = new SqlCache(metaDao, dir); }
/** * Removes a cached entity if it exists. * @param name */ public void remove(String name) { FileUtils.deleteQuietly(getCacheFile(name)); }
cache.put(LOADED_CACHE_KEY, loaded);
@Override public void clear() throws DaoException { super.clear(); cache.remove(LOADED_CACHE_KEY); }
cache.put(LOADED_CACHE_KEY, loaded);
@Override public void clear() throws DaoException { super.clear(); cache.remove(LOADED_CACHE_KEY); }
@Override public void endLoad() throws DaoException { if (labelLoader != null) labelLoader.endLoad(); if (descLoader != null) descLoader.endLoad(); if (aliasLoader != null) aliasLoader.endLoad(); labelLoader = null; descLoader = null; aliasLoader = null; super.endLoad(); if (cache != null) { cache.put("wikidata-properties", properties); } wpDs.optimize(WIKIDATA_ENTITY_LABELS); wpDs.optimize(WIKIDATA_ENTITY_ALIASES); wpDs.optimize(WIKIDATA_ENTITY_DESCRIPTIONS); wpDs.optimize(WIKIDATA_STATEMENT); }
/** * Save a named object to the cache. Name is a unique identifier for the object * The object is saved in some/standard/directory/passed/to/AbstractSqlConstructor * @param name * @param object * @throws DaoException */ public void put(String name, Object object) throws DaoException { try { FileOutputStream fos = new FileOutputStream(getCacheFile(name)); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object); oos.close(); } catch (IOException e){ throw new DaoException(e); } }
@Override public void endLoad() throws DaoException { if (labelLoader != null) labelLoader.endLoad(); if (descLoader != null) descLoader.endLoad(); if (aliasLoader != null) aliasLoader.endLoad(); labelLoader = null; descLoader = null; aliasLoader = null; super.endLoad(); if (cache != null) { cache.put("wikidata-properties", properties); } wpDs.optimize(WIKIDATA_ENTITY_LABELS); wpDs.optimize(WIKIDATA_ENTITY_ALIASES); wpDs.optimize(WIKIDATA_ENTITY_DESCRIPTIONS); wpDs.optimize(WIKIDATA_STATEMENT); }
File cacheFile = getCacheFile(name); if (!cacheFile.isFile()) { return null; FileInputStream fis = new FileInputStream(getCacheFile(name)); ObjectInputStream ois = new ObjectInputStream(fis); Object object = ois.readObject();