Skip to content

Commit 03cc85d

Browse files
committed
removed timeidle support for better performance
cleaner task runs every 10 secs
1 parent c72f808 commit 03cc85d

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

webroot/cachetests/cacheExpire.cfm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
<cfset cacheClear()>
2-
<!---<cfcache action="put" id="peter" value="Peter">--->
2+
<cfcache action="put" id="peter" value="Peter">
33
<cfcache action="put" id="susi" value="Susanna" timespan="#createTimeSpan(0,0,0,2)#">
44
<cfcache action="put" id="andrea" value="Andrea" timespan="#createTimeSpan(0,0,0,10)#">
55

66
<cfset sleep(3000)>
77

8-
<!---<cfcache action="get" id="peter" name="p">--->
8+
<cfcache action="get" id="peter" name="p">
99
<cfcache action="get" id="susi" name="s">
1010
<cfcache action="get" id="andrea" name="a">
1111

12-
<!---<cf_valueEquals left="#isDefined('p')#" right="true">--->
12+
<cf_valueEquals left="#isDefined('p')#" right="true">
1313
<cf_valueEquals left="#isDefined('s')#" right="false">
1414
<cf_valueEquals left="#isDefined('a')#" right="true">
1515

16-
<cfabort/>
17-
16+
<!--- idle not supported--->
17+
<!---
1818
<cfset cacheClear()>
1919
<cfcache action="put" id="peter" value="Peter">
2020
<cfcache action="put" id="susi" value="Susanna" idletime="#createTimeSpan(0,0,0,2)#">
21+
2122
<cfset sleep(3000)>
22-
<cfcache action="get" id="susi" name="s">
23+
2324
<cfcache action="get" id="peter" name="p">
25+
<cfcache action="get" id="susi" name="s">
26+
2427
<cf_valueEquals left="#isDefined('s')#" right="false">
2528
<cf_valueEquals left="#isDefined('p')#" right="true">
29+
--->
2630

2731

webroot/cachetests/stress/1.cfm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<cfsetting requesttimeout="180">
22

33
<cfset total = 0>
4+
<cfset cacheClear()>
45

56
<cfloop from="1" to="10" index="j">
67
<cfset start = gettickcount()>

webroot/extensions/mongodb-cache-extension/config.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<config>
33
<info>
44
<id>10EEC23A-0779-4068-9507A9C5ED4A8699</id>
5-
<version>1.2.201102091404</version>
5+
<version>1.2.201102092147</version>
66
<name>MongoDBCache</name>
77
<type>all</type>
88
<label>MongoDb Cache</label>
99
<description>MongoDb Cache Extension</description>
10-
<created>2011-February-9 14:04</created>
10+
<created>2011-February-9 21:47</created>
1111
<category>Core Extension</category>
1212
<author>Andrea Campolonghi</author>
1313
<image>http://preview.getrailo.org/logos/mongodb-logo.png</image>
Binary file not shown.

webroot/extensions/mongodb-cache-extension/src/railo/extension/io/cache/mongodb/MongoDBCache.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void init(String cacheName, Struct arguments) throws IOException {
7979
crateIndexes();
8080

8181
// start the cleaner schdule that remove entries by expires time and idle time
82-
//startCleaner();
82+
startCleaner();
8383

8484
} catch (Exception e) {
8585
e.printStackTrace();
@@ -102,13 +102,13 @@ protected void crateIndexes() {
102102
// create the indexes
103103
coll.createIndex(new BasicDBObject("key", 1));
104104
coll.createIndex(new BasicDBObject("lifeSpan", 1));
105-
coll.createIndex(new BasicDBObject("timeIdle", 1));
105+
//coll.createIndex(new BasicDBObject("timeIdle", 1)); Idle is not supported from version 2
106106
coll.createIndex(new BasicDBObject("expires", 1));
107107
}
108108

109109
protected void startCleaner() {
110110
Timer timer = new Timer();
111-
timer.schedule(new MongoDbCleanTask(this), 0, 10000);
111+
timer.schedule(new MongoDbCleanTask(this), 0, 100000);
112112
}
113113

114114
@Override
@@ -286,7 +286,8 @@ public void put(String key, Object value, Long idleTime, Long lifeSpan) {
286286

287287
Long created = System.currentTimeMillis();
288288
int create = created.intValue();
289-
int idle = idleTime == null ? 0 : idleTime.intValue();
289+
//int idle = idleTime == null ? 0 : idleTime.intValue(); idle not supported since version 2
290+
int idle = 0;
290291
int life = lifeSpan == null ? 0 : lifeSpan.intValue();
291292

292293
BasicDBObject obj = new BasicDBObject();
@@ -432,13 +433,9 @@ protected void flushInvalid(BasicDBObject query) {
432433
int nowi = now.intValue();
433434
BasicDBObject q = (BasicDBObject) query.clone();
434435

435-
436436
//execute the query
437-
System.out.println(nowi);
438437
q.append("expires", new BasicDBObject("$lt", nowi).append("$gt", 0));
439-
WriteResult wr = coll.remove(q);
440-
System.out.println(wr.getLastError());
441-
438+
coll.remove(q);
442439

443440
}
444441

0 commit comments

Comments
 (0)