ASP.NET 的 SqlCacheDependency 的 PHP 版本
我发现 SqlCacheDependency 在编写 C# ASP.NET 应用程序时非常有用,并且希望在我的 PHP 应用程序中使用类似的东西。谁能建议一下吗?
SqlCacheDependency 永远缓存页面输出,直到数据库中指定的表被修改为止。
以下是 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"]);
那么有人知道任何 MySql 表依赖技术吗? ? - 比基于时间的缓存干净得多。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用 Memcache 或 APC 为此?
编辑:我还刚刚找到了 5.3 的 MySQLnd 查询缓存 插件.3.
Why not use something like Memcache or APC for this?
Edit: I also just found the MySQLnd Query Cache plugin for 5.3.3.