关于SqlDependency/SqlCacheDependency的几个问题
我有几个问题想要解决
您可以使用 SqlDependency 或 SqlCacheDependency 来找出数据库中哪个特定数据项已更改吗?
现在,我通过一个定期检查缓存值的后台线程来使用 SqlCacheDependency。如果缓存为空,则从数据库中读取数据并将其插入到缓存中。有没有比使用后台线程定期轮询缓存更好的方法?
如果我理解正确的话,SqlDependency 通过对命令具有依赖关系来工作。一旦发生通知,就会触发 onchangeevent 。在事件处理程序中,您取消注册依赖项并创建一个新的依赖项。这个 Onchangeevent 处理程序还有其他用途吗?例如,我可以找出哪个项目已更改,从此处将新数据推送到客户端等吗?
使用 SqlCacheDependency,我相信我必须定期轮询缓存。使用 sqlDependency,我根本不需要轮询。这是真的吗?
提前致谢
I have a few questions that i would like to clear
Can u use SqlDependency or SqlCacheDependency to find out which particular data item has changed in the database?
Right now , i am using SqlCacheDependency by having a background thread that periodically checks the value of cache. If the cache is null, it reads data from database and inserts it into the cache. Is there a better way to do it rather than using a background thread for polling the cache periodically?
If i understand correctly, SqlDependency works by having a dependency for a command. Once a notification occurs, an onchangeevent is fired . In the event handler , you unregister the dependency and create a new one . Is there any other purpose for this Onchangeevent handler? For instance, can i find out which item has changed, push the new data to clients from here,etc ?
With SqlCacheDependency, i believe i have to poll the cache periodically. With sqlDependency, i need not poll at all. Is this true ?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论