如何确保内存消耗不随 redis 数据库的大小而缩放
How to ensure memory consumption is not scaling with the size of the redis database
我目前正在使用 Jedis 从 redis 数据库服务器获取我的数据。我需要将此数据推送到 MySQL。 redis 服务器中有数百万条记录。使用以下语句,我可以将数据复制到一个集合中:
String pattern = "users*";//All keys starting with users
Set<String> users = jedis.keys(pattern)//Read all the keys in to set
现在我的 users
集包含了所有记录。但是在 redis 数据库中可能有数百万条记录与我的模式匹配。这最终会耗尽我所有的记忆。我怎样才能做下面的事情
for(All the keys that match my pattern){
Set<String> set = get current to (current+10000) records from server
...Code to push 10K records to MySQL...
current = current + 10001;
}
或者请建议是否有一个优雅的方法
是的,你可以。使用 SCAN command for that. Look at Jedis Scan Test 作为用法示例。
我目前正在使用 Jedis 从 redis 数据库服务器获取我的数据。我需要将此数据推送到 MySQL。 redis 服务器中有数百万条记录。使用以下语句,我可以将数据复制到一个集合中:
String pattern = "users*";//All keys starting with users
Set<String> users = jedis.keys(pattern)//Read all the keys in to set
现在我的 users
集包含了所有记录。但是在 redis 数据库中可能有数百万条记录与我的模式匹配。这最终会耗尽我所有的记忆。我怎样才能做下面的事情
for(All the keys that match my pattern){
Set<String> set = get current to (current+10000) records from server
...Code to push 10K records to MySQL...
current = current + 10001;
}
或者请建议是否有一个优雅的方法
是的,你可以。使用 SCAN command for that. Look at Jedis Scan Test 作为用法示例。