Skip to content

Commit

Permalink
clear ram cache when reset
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Oct 2, 2023
1 parent 548e555 commit 92f0343
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/main/cfml/context/admin/services.restart.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Error Output --->
$.get("?", function(response) {
window.location=('?action=overview');
});
}, 1000); // give Lucee enough time to startup, otherwise, the admin login may show without css/js
}, 5000); // give Lucee enough time to startup, otherwise, the admin login may show without css/js
} else {
$('##updateInfoDesc').addClass("error").attr("style", null).html(response);
//window.location=('?action=#url.action#');
Expand Down
13 changes: 12 additions & 1 deletion core/src/main/java/lucee/runtime/cache/ram/RamCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
public class RamCache extends CacheSupport {

public static final int DEFAULT_CONTROL_INTERVAL = 60;

private static Map<RamCache, String> ramCaches = new ConcurrentHashMap<>();

private Map<String, Ref<RamCacheEntry>> entries = new ConcurrentHashMap<String, Ref<RamCacheEntry>>();
private long missCount;
private int hitCount;
Expand All @@ -62,6 +65,12 @@ public class RamCache extends CacheSupport {
private Thread controller;
private boolean outOfMemory;

public static void doNotifyAll(CFMLEngineImpl cfmlEngineImpl) {
for (RamCache rc: ramCaches.keySet()) {
SystemUtil.notify(rc);
}
}

// this is used by the config by reflection
public RamCache() {
Config config = ThreadLocalPageContext.getConfig();
Expand Down Expand Up @@ -232,7 +241,9 @@ public Controler(CFMLEngineImpl engine, RamCache ramCache) {
public void run() {
while (engine.isRunning()) {
try {
SystemUtil.sleep(ramCache.controlInterval);
ramCaches.put(ramCache, "");
SystemUtil.wait(ramCache, ramCache.controlInterval);
ramCaches.remove(ramCache);
_run();
}
catch (Exception e) {
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/lucee/runtime/engine/CFMLEngineImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
import lucee.runtime.PageSource;
import lucee.runtime.PageSourceImpl;
import lucee.runtime.cache.CacheUtil;
import lucee.runtime.cache.ram.RamCache;
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigAdmin;
import lucee.runtime.config.ConfigFactory;
Expand Down Expand Up @@ -1317,7 +1318,7 @@ public void reset() {
@Override
public void reset(String configId) {
if (!controlerState.active()) return;

controlerState.setActive(false);
try {
LogUtil.log(configServer, Log.LEVEL_INFO, "startup", "Reset CFML Engine");

Expand Down Expand Up @@ -1345,6 +1346,9 @@ public void reset(String configId) {

if (config != null && config.getIdentification() != null && configId != null && !configId.equals(config.getIdentification().getId())) continue;

// RAM cache
RamCache.doNotifyAll(this);

// scheduled tasks
SchedulerImpl scheduler = ((SchedulerImpl) config.getScheduler());
if (scheduler != null) scheduler.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void sleepEL(long when, long now) {
if (millis > 0) {
while (true) {
SystemUtil.wait(this, millis);
if (stop) break;
if (stop || this.engine != null && !this.engine.isRunning()) break;
millis = when - System.currentTimeMillis();
if (millis <= 0) break;
millis = 10;
Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.0.0.570-SNAPSHOT"/>
<property name="version" value="6.0.0.571-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.0.0.570-SNAPSHOT</version>
<version>6.0.0.571-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit 92f0343

Please sign in to comment.