Search in sources :

Example 1 with LongWaitResultCacheEntry

use of org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry in project carbon-identity-framework by wso2.

the class CacheBackedLongWaitStatusDAO method getWaitStatus.

public LongWaitStatus getWaitStatus(String waitKey) throws FrameworkException {
    LongWaitStatus status = null;
    LongWaitResultCacheEntry valueFromCache = LongWaitResultCache.getInstance().getValueFromCache(new LongWaitResultCacheKey(waitKey));
    if (valueFromCache != null) {
        status = valueFromCache.getWaitStatus();
    }
    if (status == null) {
        status = waitStatusDAO.getWaitStatus(waitKey);
        LongWaitResultCacheKey cacheKey = new LongWaitResultCacheKey(waitKey);
        LongWaitResultCacheEntry cacheEntry = new LongWaitResultCacheEntry(status);
        LongWaitResultCache.getInstance().addToCache(cacheKey, cacheEntry);
    }
    return status;
}
Also used : LongWaitResultCacheKey(org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheKey) LongWaitStatus(org.wso2.carbon.identity.application.authentication.framework.model.LongWaitStatus) LongWaitResultCacheEntry(org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry)

Example 2 with LongWaitResultCacheEntry

use of org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry in project carbon-identity-framework by wso2.

the class CacheBackedLongWaitStatusDAO method addWaitStatus.

public void addWaitStatus(int tenantId, String waitKey, LongWaitStatus status, Timestamp createdTime, Timestamp expireTime) throws FrameworkException {
    if (waitKey != null) {
        // Add to database.
        waitStatusDAO.addWaitStatus(tenantId, waitKey, status, createdTime, expireTime);
        // Add to cache.
        LongWaitResultCacheKey cacheKey = new LongWaitResultCacheKey(waitKey);
        LongWaitResultCacheEntry cacheEntry = new LongWaitResultCacheEntry(status);
        LongWaitResultCache.getInstance().addToCache(cacheKey, cacheEntry);
    }
}
Also used : LongWaitResultCacheKey(org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheKey) LongWaitResultCacheEntry(org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry)

Example 3 with LongWaitResultCacheEntry

use of org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry in project carbon-identity-framework by wso2.

the class CacheBackedLongWaitStatusDAO method removeWaitStatus.

public void removeWaitStatus(String waitKey) throws FrameworkException {
    waitStatusDAO.removeWaitStatus(waitKey);
    // Add status as completed.
    LongWaitResultCacheKey cacheKey = new LongWaitResultCacheKey(waitKey);
    LongWaitStatus status = new LongWaitStatus();
    status.setStatus(LongWaitStatus.Status.UNKNOWN);
    LongWaitResultCacheEntry cacheEntry = new LongWaitResultCacheEntry(status);
    LongWaitResultCache.getInstance().addToCache(cacheKey, cacheEntry);
}
Also used : LongWaitResultCacheKey(org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheKey) LongWaitStatus(org.wso2.carbon.identity.application.authentication.framework.model.LongWaitStatus) LongWaitResultCacheEntry(org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry)

Aggregations

LongWaitResultCacheEntry (org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheEntry)3 LongWaitResultCacheKey (org.wso2.carbon.identity.application.authentication.framework.cache.LongWaitResultCacheKey)3 LongWaitStatus (org.wso2.carbon.identity.application.authentication.framework.model.LongWaitStatus)2