V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ZeddShi
V2EX  ›  Python

Python web 接口怎么缓存上一次接口请求的时间?

  •  
  •   ZeddShi · 2018-10-15 11:14:42 +08:00 · 1407 次点击
    这是一个创建于 2013 天前的主题,其中的信息可能已经有所发展或是发生改变。

    小弟刚转 python 后端开发几个月,不是很熟,希望大佬们能指导指导

    1. 每个用户的user_id对应的接口请求时间要分别缓存
    2. 缓存上一次接口的请求时间是为了获取上一次请求时间到这次的请求时间之间那段时间的用户行为
    3. 小程序端不会缓存时间,请求参数只带user_id

    目前想用 redis 缓存每个用户的接口上次请求,但是感觉用户如果很多,那么 key 太多了,会不会处理的不太优美。不知道有没有更好的方法?

    2 条回复    2018-10-16 11:11:09 +08:00
    matrix1010
        1
    matrix1010  
       2018-10-15 20:31:20 +08:00
    获取用户行为?那应该看 log,log 里也有时间
    frostming
        2
    frostming  
       2018-10-16 11:11:09 +08:00
    写 DB 啊,反正就一个字段,每次覆盖掉就好了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   943 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:05 · PVG 04:05 · LAX 13:05 · JFK 16:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.