Code example for Cache

Methods: getIfPresentput

    public Long getSchemaId(final String schemaName, final StandardTitanTx tx) {
        ConcurrentMap<String,Long> types = typeNames;
        Long id;
        if (types==null) {
            id = typeNamesBackup.getIfPresent(schemaName);
            if (id==null) {
                id = retriever.retrieveSchemaByName(schemaName, tx);
                if (id!=null) { //only cache if type exists
        } else { 
            id = types.get(schemaName);
            if (id==null) { //Retrieve it
                if (types.size()> maxCachedTypes) {
                    /* Safe guard against the concurrent hash map growing to large - this would be a VERY rare event 
                    as it only happens for graph databases with thousands of types. 
                    typeNames = null;