Pergunta

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.

Foi útil?

Solução

Why not use something like Memcache or APC for this?

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top