简体   繁体   中英

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 in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM