honmaple
V2EX  ›  Redis

怎么用 redis 存储用户操作?

  •  
  •   honmaple · Jan 8, 2016 · 4398 views
    This topic created in 3785 days ago, the information mentioned may be changed or developed.
    sadd visited:user visited_user:127.0.0.1
    hset visited_user:127.0.0.1 visited_page:/xxx 20
    hincrby visited_user:127.0.0.1 visited_page:/xxx 1
    

    第一次使用 redis ,我想要统计访问过的用户,以及用户访问过页面的次数,不知道行不行,如果要同时记录用户访问的时间和上次访问的时间,又该怎么做,除了再次使用

    het visited_user:127.0.0.1 visited:time 2016-1-8

    redis 操作类似一对多的关系难道只能用 hset

    3 replies    2016-01-18 14:56:58 +08:00
    cloudzhou
        1
    cloudzhou  
       Jan 8, 2016
    sortedset
    cheng007
        2
    cheng007  
       Jan 9, 2016
    redis 并不适合做统计。

    做统计用 MySQL 还更方便,容易
    wooyin
        3
    wooyin  
       Jan 18, 2016
    用 mongodb
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1176 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 17:46 · PVG 01:46 · LAX 10:46 · JFK 13:46
    ♥ Do have faith in what you're doing.