All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.fhir.persistence.jdbc.dao.api.INameIdCache Maven / Gradle / Ivy

There is a newer version: 4.11.1
Show newest version
/*
 * (C) Copyright IBM Corp. 2020, 2021
 *
 * SPDX-License-Identifier: Apache-2.0
 */

package com.ibm.fhir.persistence.jdbc.dao.api;

import java.util.Collection;
import java.util.Map;

/**
 * Interface to a cache mapping a string to a value of type T. Supports
 * thread-local caching to support temporary staging of values pending
 * successful completion of a transaction.
 * @param
 */
public interface INameIdCache {

    /**
     * Get the resource type identifier for the given resourceType name
     * @param resourceType
     * @return
     */
    T getId(String resourceType);
    
    /**
     * Get all resource type identifiers in the cache
     * @return
     */
    Collection getAllIds();
    
    /**
     * Add the resource type to the local cache
     * @param resourceType
     * @param resourceTypeId
     */
    void addEntry(String key, T id);

    /**
     * Called after a transaction commit() to transfer all the staged (thread-local) data
     * over to the shared cache.
     */
    void updateSharedMaps();

    /**
     * Clear both local  shared caches - useful for unit tests
     */
    void reset();
    
    /**
     * Clear anything cached in thread-local (after transaction rollback, for example)
     */
    void clearLocalMaps();

    /**
     * Prefill the shared map with the given content (must come data already 
     * committed in the database)
     * @param content
     */
    void prefill(Map content);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy