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 | 1582 Views | 15% / 14% 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 | 1321 Views | 13% / 14% 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 Wordsset on the Settingspage.
  • Refresh Bad IP Cache- will refresh the Bad IPsset on the Settingspage.
  • 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 | 2555 Views | 24% / 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 1ssBlogis 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 1ssBloginstance, 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/cachingfolder and then the right location set in the Settingspage 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 1ssBlogi 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 | 1705 Views | 16% / 29% 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 | 986 Views | 9% / 0% Popularity


Posted At : Dec 18, 2007 1:49 AM | Posted By : Ed Tabara
Related Categories: ColdFusion, Caching

Jon Hirschi have done an awesome job on external caching for coldfusion with memcached.

Comments (0)| Print| Send | 1064 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
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:

.... here goes pod code ...

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):

", application.SCOPECACHE[application.applicationName].value, 1)>", application.SCOPECACHE[application.applicationName].value, 1)-1)>", application.SCOPECACHE[application.applicationName].value, 1)+Len(podElement)+2)>

So.. what do we have here..
First of all, in the notCachedPodNamesvariable we set all the pod names for the pods that we don't want to be cached and in notCachedPodFilesthe 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 ) and save in thisAppVar1the first part of the source. Then we delete from the top everything including the close tag for the current pod name (for example ). Now we save in the thisAppVar2variable 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, thisAppVar2and 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 (2)| Print| Send | 1325 Views | 13% / 14% Popularity