ai.grakn.kb.internal.cache.GlobalCache Maven / Gradle / Ivy
/*
* GRAKN.AI - THE KNOWLEDGE GRAPH
* Copyright (C) 2018 Grakn Labs Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package ai.grakn.kb.internal.cache;
import ai.grakn.GraknConfigKey;
import ai.grakn.concept.Label;
import ai.grakn.concept.LabelId;
import ai.grakn.concept.SchemaConcept;
import ai.grakn.engine.GraknConfig;
import ai.grakn.kb.internal.concept.SchemaConceptImpl;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
*
* Tracks Knowledge Base Specific Variables
*
*
*
* Caches Knowledge Base or Session specific data which is shared across transactions:
*
* - Schema Cache - All the types which make up the schema. This cache expires
* -
* Label Cache - All the labels which make up the schema. This can never expire and is needed in order
* to perform fast lookups. Essentially it is used for mapping labels to ids.
*
*
*
*
* @author fppt
*
*/
public class GlobalCache {
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
//Caches
private final Cache
© 2015 - 2025 Weber Informatics LLC | Privacy Policy