For those who occasionally read my blog, you should know that we still have some applications written in classic ASP.
One of the problems of the ASP is the lack of method of caching.
The only ways to cache data are to write files to disk or mount information in the application object.
So we decided to create a COM object to enable the ASP to communicate with Memcached.
I found on the official list of clients, a good C# client called Memcached BEIT.
With this implementation in C #, it becomes quite easy to create a COM component.
There are some limitations: it can only send simple data types or arrays. But it’s not need trying to send a recordset, the system will fail to serialize.
You can download the archive containing the sources here.
An example of a call from an asp or vbs script:
set oMemcache = createobject("memcacheCOM.memcache")
Call oMemcache.set ("mykey", "myvalue", 3600)
wscript.echo oMemcache.get ("mykey")
Call oMemcache.delete ("mykey")
dim tTest(2) : tTest(0) = "aaa" : tTest(1) = "bbb"
Call oMemcache.set ("myArray", (tTest), 30)
set oMemcache = nothing
In order to use the COM component, you need to do the following things:
From this moment you should be able to connect to memcached from your asp or vbs scripts.
But we must also do something, because under load you may encounter the following error:
ErrorCode ASP 0177: 8000ffff
Description Server.CreateObject Failed
It’s a known issue with Microsoft Updates, just do the following things:
- give the IUSR (or whoever your site is running as) Read access to HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
After applying the workaround, unregister and re-register the MemcacheCOM component and recycle the IIS app pool.
Thanks to ceTe Software moderator for the workaround: http://www.cete.com/Forums/DisplayThread.csp?ForumId=39&ThreadId=2785