如何实现与数据库同步了Memcached [英] How to implement synchronized Memcached with database

查看:224
本文介绍了如何实现与数据库同步了Memcached的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,Memcached的不支持与数据库同步(至少SQL Server和Oracle)。我们计划使用Memcached的(这是免费的)与我们的OLTP数据库。

AFAIK, Memcached does not support synchronization with database (at least SQL Server and Oracle). We are planning to use Memcached (it is free) with our OLTP database.

在一些业务流程,我们做一些繁重的验证,需要大量从数据库中的数据,我们不能让这些数据的静态副本,因为我们不知道数据是否已经被修改,所以我们每次减慢时间获取数据并下跌过程。

In some business processes we do some heavy validations which requires lot of data from database, we can not keep static copy of these data as we don't know whether the data has been modified so we fetch the data every time which slows the process down.

一种可能的解决办法是


  1. 写触发数据库创建/更新prefixed-后缀(表-PK1,PK2,PK3柱)上记录变化的文件

  2. 进行监控文件的这一变化 FileSystemWatcher的和过期的密钥(表-PK1,PK2,PK3列),以获得更新的数据

  1. Write triggers on database to create/update prefixed-postfixed (table-PK1-PK2-PK3-column) files on change of records
  2. Monitor this change of file using FileSystemWatcher and expire the key (table-PK1-PK2-PK3-column) to get updated data

问题:将会有10万左右的用户使用数据的任意组合10小时。因此,我们就会有很多文件例如categ1-subcateg5-subcateg-78-data100,categ1-subcateg5-subcateg-78-data250,categ2-subcateg5-subcateg-78-data100,categ1-subcateg5-subcateg-33-data100等。

Problem: There would be around 100,000 users using any combination of data for 10 hours. So we will end up having a lot of files e.g. categ1-subcateg5-subcateg-78-data100, categ1-subcateg5-subcateg-78-data250, categ2-subcateg5-subcateg-78-data100, categ1-subcateg5-subcateg-33-data100, etc.

我期待500万文件最少。现在看起来可怜的解决方案:(

I am expecting 5 million files at least. Now it looks a pathetic solution :(

其他的可能性是


  1. 异步从触发调用Web服务传递的关键
    就过期

  2. 拨叫触发一个exe,无需等待它完成,然后这
    exe文件将到期的关键。 (我有一些成功使用xp_cmdsell调用一个exe SQL Server上的这种态度,要求从甲骨文的触发一个exe看起来有点困难

  1. call a web service asynchronously from the trigger passing the key to be expired
  2. call an exe from trigger without waiting it to finish and then this exe would expire the key. (I have got some success with this approach on SQL Server using xp_cmdsell to call an exe, calling an exe from oracle's trigger looks a bit difficult)

听起来还是可悲,不是吗?

Still sounds pathetic, isn't it?

任何智能建议请

推荐答案

MS SQL Server有更改跟踪功能,也许是有用的给你。在启用更改跟踪数据库和配置要跟踪哪些表。然后SQL Server创建改变每一个更新,插入记录,删除在桌子上,然后让您查询,因为你上次检查已做了更改的记录。这是要进行同步的变化非常有用,并且比使用触发器更有效。它也更容易比制作自己的跟踪表来管理。因为SQL Server 2005中这是一个特点。

MS SQL Server has "Change Tracking" features that maybe be of use to you. You enable the database for change tracking and configure which tables you wish to track. SQL Server then creates change records on every update, insert, delete on a table and then lets you query for changes to records that have been made since the last time you checked. This is very useful for syncing changes and is more efficient than using triggers. It's also easier to manage than making your own tracking tables. This has been a feature since SQL Server 2005.

如何:使用SQL Server更改跟踪

变更跟踪仅捕获表的主键,并让您查询哪些领域可能已被修改。然后你就可以查询表上的那些键加入,以获得当前数据。如果你想要捕捉的数据也可以使用更改捕捉,但它需要更多的开销,至少SQL Server 2008企业版。

Change tracking only captures the primary keys of the tables and let's you query which fields might have been modified. Then you can query the tables join on those keys to get the current data. If you want it to capture the data also you can use Change Capture, but it requires more overhead and at least SQL Server 2008 enterprise edition.

变化数据捕捉

我与甲骨文没有经验,但我相信它可能也有一定的跟踪功能,以及。这篇文章可能让你开始:

I have no experience with Oracle, but i believe it may also have some tracking functionality as well. This article might get you started:

20使用Oracle流以记录表更改

这篇关于如何实现与数据库同步了Memcached的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆