V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
guyeuro
V2EX  ›  问与答

RedisTemplate 如何检查某个 key 是否存在?

  •  
  •   guyeuro · Aug 23, 2017 · 20344 views
    This topic created in 3175 days ago, the information mentioned may be changed or developed.
    13 replies    2017-08-24 15:31:03 +08:00
    zjp
        1
    zjp  
       Aug 23, 2017 via Android
    get() 然后判断是否为 null 不行吗
    guyeuro
        2
    guyeuro  
    OP
       Aug 23, 2017
    @zjp hash 和 set 的键呢
    guyeuro
        3
    guyeuro  
    OP
       Aug 23, 2017
    @guyeuro get 有 nullpointexception 啊
    irockytan
        4
    irockytan  
       Aug 23, 2017 via iPhone
    api 文档看看,有 exist 和 hexist 的
    guyeuro
        5
    guyeuro  
    OP
       Aug 23, 2017
    @irockytan 没有啊,哪里的文档说有?
    KillThunder
        6
    KillThunder  
       Aug 23, 2017
    EXISTS key
    检查给定 key 是否存在。
    guyeuro
        7
    guyeuro  
    OP
       Aug 23, 2017   ❤️ 1
    @KillThunder 这是 redis 的命令,不是 redistemplate 里的啊
    251804746
        8
    251804746  
       Aug 23, 2017
    valueOperations.getOperations().hasKey("");
    LaudOak
        9
    LaudOak  
       Aug 23, 2017
    LaudOak
        10
    LaudOak  
       Aug 23, 2017


    RedisTemplate#hasKey(K key)
    ooTwToo
        11
    ooTwToo  
       Aug 23, 2017 via Android
    进去看看有哪些方法再来问。。
    GoGoGoBoy
        12
    GoGoGoBoy  
       Aug 23, 2017 via iPhone
    @LaudOak 为什么设计成回掉模式???
    KillThunder
        13
    KillThunder  
       Aug 24, 2017
    @guyeuro redistemplate 和 jedis 有什么区别吗?哪个比较好用?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2479 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 12:05 · PVG 20:05 · LAX 05:05 · JFK 08:05
    ♥ Do have faith in what you're doing.