简体   繁体   English

我可以将Redis数据保留在Oracle数据库中吗?

[英]Can I persist redis data in Oracle Database?

We are trying to implement caching through Redis I understand that it stores data into its own format RDB files. 我们正在尝试通过Redis实现缓存,据我所知,Redis将数据存储为自己的格式RDB文件。 But we already have Oracle persistence which is used by other clients. 但是我们已经有了其他客户端使用的Oracle持久性。 So instead of storing in RDB files we would like to persist the data in Oracle DB. 因此,我们希望将数据保留在Oracle DB中,而不是存储在RDB文件中。

Disable the file writing in this case, and use Redis as a pure in-memory cache. 在这种情况下,请禁用文件写入,并将Redis用作纯内存缓存。 To do it just comment all the "save" lines in redis.conf. 为此,只需在redis.conf中注释所有“保存”行。

In pseudo code, reading a value should be done like this: 在伪代码中,应按以下方式读取值:

result = get value from redis
if(result is null)
{
   result = get value from Oracle
   store result in redis
}
return result

Update: after some exchange in comments here is an alternative 更新:在交换了一些评论后,这里是另一种选择

Create a fake redis slave, which will connect to the Redis instance and then reproduce the write operations on the Oracle database. 创建一个伪造的redis从服务器,它将连接到Redis实例,然后在Oracle数据库上重现写操作。 Look at redis documentation to see how replication works. 查看redis文档以了解复制的工作方式。

But it's not a trivial thing to do. 但这不是一件容易的事。 You'll have to interpret Redis commands and apply corresponding SQL commands, and handle resynchronization when the Oracle Database fails. 您将必须解释Redis命令并应用相应的SQL命令,并在Oracle数据库失败时处理重新同步。 The performances will depend on the number of write operations. 性能将取决于写入操作的数量。 If they are too numerous, the Oracle database could not be able to cope with them. 如果数量太多,Oracle数据库将无法应对。 So once again, I don't think it's a recommended architecture. 再一次,我不认为这是推荐的体系结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM