Code example for Cache

Methods: getIfPresentput

0
    @Override 
    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
                    typeNamesBackup.put(schemaName,id);
                } 
            } 
        } 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;
Stop searching for code, let great code find you!  Add Codota to your java IDE