Posted At : May 07, 2008 16:24 PM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
My Projects,
Other,
Caching,
1ssBlog
"Smart Caching" is my try to make the caching process a little bit more inteligent and i've made it on the example of 1ssBlog. It allow the entries to be cached and de-cached automatically based on how often they are viewed.
How it work:
We set the period of time (1 day, 1 hour or 1 minute) and the number of unique views that should happen in that period of time in order the entry to get cached automatically.
So, if we set the period to 1 hour and the number of views to 30, then as soon as an entry will be viewd 30 times in a period of the specified length, the entry will get cached. But if after some time the entry will not get enough views in a period of specified length, the entry will de removed from the cache automaticaly.
Nice and easy, huh? But it make the caching process flexible.
I would like to hear of others think about it.
Comments (2) |
Print |
Send
| 2724 Views
| 14% / 13% Popularity
Posted At : Mar 21, 2008 19:31 PM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
My Projects,
Caching,
1ssBlog
The Triggers here are a way to have some pods re-cached automatically when an event happen. Right now it can be done for 2 events:
- Add/Delete/Approve Comment
- Delete entry or entry become live
Have a nice weekend everyone!
Comments (2) |
Print |
Send
| 2203 Views
| 11% / 13% Popularity
Posted At : Mar 20, 2008 17:47 PM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
My Projects,
Caching,
1ssBlog
At this moment there are 6 different options for cache refresh in 1ssBlog:
- Refresh App Cache - will refresh the entire application. Pretty much it would be like if it would be the first run after ColdFusion restart.
- Refresh Posts Cache - this will refresh only the posts. So, when you add a new entry, this would be the choice.
- Refresh Pods Cache - will refresh only the pods. For example it would be helpfull when a new pod is added or some settings of current pods are changed.
- Refresh Bad Words Cache - as said, will refresh the Bad Words set on the Settings page.
- Refresh Bad IP Cache - will refresh the Bad IPs set on the Settings page.
- Refresh Smiles Cache - if you add, delete or update some smiles images, this will be the one to go.
If anyone think any other cache refreshing options are needed, let me know.
Comments (0) |
Print |
Send
| 3608 Views
| 18% / 0% Popularity
Posted At : Mar 14, 2008 21:40 PM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
My Projects,
Caching,
1ssBlog
One of the things i like in 1ssBlog is the option to use pretty much any caching mechanism you want. Because this was one of the main ideas behind the whole thing, it was done from the start. So, what you will have to do in order to use a new caching mechanism with you 1ssBlog instance, is to make sure it have the following methods:
- cacheInit - will initialize your caching mechanism.
- cacheSetElement - will set an elemnt to the given value.
- cacheGetElement - will return the value of the requested cached element.
- cacheRemoveElement - will remove from the cache the given element.
- cacheShutdown - will delete all your cached elements.
If any of the above functions are not needed, just make them empty.
The CFC for your caching mechanism should be placed into the com/caching folder and then the right location set in the Settings page of your admin backoffice. And finally use the "Refresh App Cache" lick to reload your application with cache and everything else.
Right now you have 3 options to use for caching mechanism:
- com.caching.appCache - nothing fancy but made by me, so it's used as the default one hehe
- com.caching.softcache - softcache by Ashwin Mathew
- com.caching.universalmind.ehCache.ehCacheManager - ColdFusion version for ehCache by Andrew Powell
In a more or less near time i will try to make it possible for memcache to be used as well. But if anyone will make it before that or will create the interface for other caching mechanisms to be used with 1ssBlog i would love to know about that too and if the author will be fine with that it will can be added to the package.
Comments (4) |
Print |
Send
| 2588 Views
| 13% / 25% Popularity
Posted At : Dec 18, 2007 11:04 AM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
Caching
After Jon Hirschi yesterday's post on caching in ColdFusion with memcached, i searched for a windows version of memcached server and i did find it.
So, if anyone interested, you can get it
here
Comments (0) |
Print |
Send
| 1730 Views
| 9% / 0% Popularity
Posted At : Dec 18, 2007 1:49 AM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
Caching
Comments (0) |
Print |
Send
| 1891 Views
| 10% / 0% Popularity
Posted At : Oct 07, 2007 22:52 PM
| Posted By : Ed Tabara
Related Categories:
ColdFusion,
Caching
Ok. Seems like i've got it working.
First i tried this
<cfmodule template="tags/scopecache.cfm" scope="application" clearall="true" cachename="podName">
in Application.cfm and it helped. BUT as result the pages were loading over 2 seconds each time. and of course it was not acceptable
So, i went from Rob Wilkerson's idea of substituting a part of the cached version of the entire page with the needed part. But the problem is that theoretically it's not known what exactly and with what exactly should be changed (because of the dynamic nature of what should be changed and/or because i wanted to make it generalized enough).
So i had to find or have some kind of markers that will allow uniquily identify the needed parts of the source html. And this is not difficult. This way i came to the following process:
1. Inside the pod script, around the code that will be output on the blog, i place a tag that does not really exists. In order to make it simple, i decided to use as so the name given to the pod. So, the pod's script will look something like this:
<podName>
....
here goes pod code
...
</podName>
2. In Applicatiion.cfm, somewhere at the top but after the CFAPPLICATION tag do a CFINCLUDE of a file with the following code (i placed it right after udf.cfm's cfinclude):
<cfset notCachedPodNames = "podName|podName2|podName3">
<cfset notCachedPodFiles = "pod1.cfm|pod2.cfm|pod3.cfm">
<cfif IsDefined("application.SCOPECACHE") and StructKeyExists(application.SCOPECACHE, application.applicationName)>
<cfloop index="podListPoz" from="1" to="#ListLen(notCachedPodNames, '|')#">
<cfset podElement = ListGetAt(notCachedPodNames, podListPoz, "|")>
<cfset podFileElement = ListGetAt(notCachedPodFiles, podListPoz, "|")>
<cfif FindNoCase("<#podElement#>", application.SCOPECACHE[application.applicationName].value, 1)>
<cfset thisAppVar1 = Left(application.SCOPECACHE[application.applicationName].value, FindNoCase("<#podElement#>", application.SCOPECACHE[application.applicationName].value, 1)-1)>
<cfset application.SCOPECACHE[application.applicationName].value = RemoveChars(application.SCOPECACHE[application.applicationName].value, 1, FindNoCase("</#podElement#>", application.SCOPECACHE[application.applicationName].value, 1)+Len(podElement)+2)>
<cfsavecontent variable="thisAppVar2"><cfinclude template="includes/pods/#podFileElement#"></cfsavecontent>
<cfset application.SCOPECACHE[application.applicationName].value = thisAppVar1 & thisAppVar2 & application.SCOPECACHE[application.applicationName].value>
</cfif>
</cfloop>
</cfif>
So.. what do we have here..
First of all, in the notCachedPodNames variable we set all the pod names for the pods that we don't want to be cached and in notCachedPodFiles the actual names of that pods. Then we do a loop for the number of elements in that lists and do the needed substitution. As can be seen, first the script look for the open tag of the current pod name (for example <podName1>) and save in thisAppVar1 the first part of the source. Then we delete from the top everything including the close tag for the current pod name (for example </podName1>). Now we save in the thisAppVar2 variable the execution of the current pod. And finally we replace the existing cache for the page html source (application.SCOPECACHE[application.applicationName].value) with the concatenated values of thisAppVar1, thisAppVar2 and the rest of application.SCOPECACHE[application.applicationName].value.
All DONE. Now our cache contain the modified version of the html source. And it work FAST. For me, loading the blog with that process inside, rarely goes over 70 milliseconds.
Comments (3) |
Print |
Send
| 2647 Views
| 13% / 19% Popularity