开发者

PHP version of ASP.NET's SqlCacheDependency

I find the SqlCacheDependency very useful when writing C# ASP.NET applications, and would love to use something similar in my PHP applications. Can anyone suggest something?

SqlCacheDependency caches the page page output forever, until the specified table(s) are modified in the database.

Here's the basic jist of what happens 开发者_如何学JAVAin ASP.NET:

SqlCacheDependency SqlDep = null; 

// Check the Cache for the SqlSource key. 
// If it isn't there, create it with a dependency 
// on a SQL Server table using the SqlCacheDependency class. 
if (Cache["MyCache"] == null) { 
    SqlDep = new SqlCacheDependency("DatabaseName", "TableName"); 

    // Perform action to be cached ...
    var result = DatabaseIntensiveFunction();
    Cache.Insert("MyCache", result, SqlDep);
} 

else { 
    // The data was retrieved from the Cache.
}

// Output page from cache.
Output(Cache["MyCache"]);

So does anyone know of any MySql table dependency technique? - much cleaner than time-based caching.


Why not use something like Memcache or APC for this?

Edit: I also just found the MySQLnd Query Cache plugin for 5.3.3.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜