ASP.NET 的 SqlCacheDependency 的 PHP 版本

发布于 2024-10-05 23:14:21 字数 801 浏览 0 评论 0原文

我发现 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坠似风落 2024-10-12 23:14:21

为什么不使用 MemcacheAPC 为此?

编辑:我还刚刚找到了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文