【问题标题】:Redis behavior with multiple concurrent programs doing read/del on the same hash key多个并发程序在同一个哈希键上执行读取/删除的 Redis 行为
【发布时间】:2013-06-20 21:51:02
【问题描述】:

我有一个程序 (program_1)(基于 Jedis)定期写入 Redis HASH (KEY_1)。我有另一个定期执行的程序 (program_2)(单独的 JVM 进程),并且在 Redis 事务中执行以下操作:

        Transaction transaction = redis.multi();
        //get the current entity table
        Response<Map<String, String>> currentEntityTableResponse = transaction.hgetAll(KEY_1);
        transaction.del(KEY_1);
        transaction.exec();

我的假设是,当 program_2 删除了 HASH(使用 KEY_1)时,下一次 program_1 运行它会再次创建 HASH。它是否正确 ?

【问题讨论】:

    标签: concurrency transactions redis jedis


    【解决方案1】:

    是的。 Redis is single threadedtransactions block until they finish,所以如果program_2启动了,当program1再次运行时,哈希KEY_1就不再存在了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-05
      • 2019-03-24
      • 2016-02-06
      • 2010-12-06
      • 2011-09-07
      • 2021-11-08
      • 2016-03-03
      相关资源
      最近更新 更多