Search in sources :

Example 1 with StorageValue

use of lucee.runtime.type.scope.storage.StorageValue in project Lucee by lucee.

the class ClientCache method getInstance.

/**
 * load an new instance of the client datasource scope
 * @param cacheName
 * @param appName
 * @param pc
 * @param log
 * @return client datasource scope
 * @throws PageException
 */
public static Client getInstance(String cacheName, String appName, PageContext pc, Client existing, Log log) throws PageException {
    if (appName != null && appName.startsWith("no-in-memory-cache-"))
        existing = null;
    synchronized (token) {
        StorageValue sv = _loadData(pc, cacheName, appName, "client", log);
        if (sv != null) {
            long time = sv.lastModified();
            if (existing instanceof StorageScopeCache) {
                if (((StorageScopeCache) existing).lastModified() >= time)
                    return existing;
            }
            return new ClientCache(pc, cacheName, appName, sv.getValue(), time);
        } else if (existing != null)
            return existing;
        ClientCache cc = new ClientCache(pc, cacheName, appName, new StructImpl(), 0);
        cc.store(pc);
        return cc;
    }
}
Also used : StructImpl(lucee.runtime.type.StructImpl) StorageValue(lucee.runtime.type.scope.storage.StorageValue) StorageScopeCache(lucee.runtime.type.scope.storage.StorageScopeCache)

Example 2 with StorageValue

use of lucee.runtime.type.scope.storage.StorageValue in project Lucee by lucee.

the class SessionCache method getInstance.

/**
 * load an new instance of the client datasource scope
 * @param cacheName
 * @param appName
 * @param pc
 * @return client datasource scope
 * @throws PageException
 */
public static Session getInstance(String cacheName, String appName, PageContext pc, Session existing, Log log) throws PageException {
    if (appName != null && appName.startsWith("no-in-memory-cache-"))
        existing = null;
    synchronized (token) {
        StorageValue sv = _loadData(pc, cacheName, appName, "session", log);
        if (sv != null) {
            long time = sv.lastModified();
            if (existing instanceof StorageScopeCache) {
                if (((StorageScopeCache) existing).lastModified() >= time) {
                    return existing;
                }
            }
            return new SessionCache(pc, cacheName, appName, sv.getValue(), time);
        } else if (existing != null) {
            return existing;
        }
        SessionCache session = new SessionCache(pc, cacheName, appName, new StructImpl(), 0);
        session.store(pc);
        return session;
    }
}
Also used : StructImpl(lucee.runtime.type.StructImpl) StorageValue(lucee.runtime.type.scope.storage.StorageValue) StorageScopeCache(lucee.runtime.type.scope.storage.StorageScopeCache)

Aggregations

StructImpl (lucee.runtime.type.StructImpl)2 StorageScopeCache (lucee.runtime.type.scope.storage.StorageScopeCache)2 StorageValue (lucee.runtime.type.scope.storage.StorageValue)2