推荐学习书目
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
shanechiu
V2EX  ›  Python

Is there any difference between session and memcahed or redis? If it is,and what is that?

  •  
  •   shanechiu ·
    shanezhiu · Dec 11, 2017 · 3795 views
    This topic created in 3106 days ago, the information mentioned may be changed or developed.

    I am confused about session,memcached/redis.

    I often store the login infor into a memcached server or a redis, and then could we call that is a session?

    if not,what does a session point and what's the

    difference between memcached/redis and session? I have looked up into google,but I can not understand it still.

    So,could you do me a favor? Thanks in advance!

    Append:

    I am a new fish on HTTP, and if this question makes you unhappy, you'd better to forget it. LOL...

    Supplement 1  ·  Dec 11, 2017
    Firstly, I would not like to make an argument with anybody.


    Somebody said you went against public order and good morals in this community.

    I am not clear about that, and then I searched on Wikipedia and Baike. Share with you.

    1. 公序良俗 https://baike.baidu.com/item/%E5%85%AC%E5%BA%8F%E8%89%AF%E4%BF%97#2
    2. 公序良俗 https://ja.wikipedia.org/wiki/%E5%85%AC%E5%BA%8F%E8%89%AF%E4%BF%97

    I went through it, and as a result, it seems like I did nothing against public order and good morals.

    Ok, if there is any on v2ex, you can show me.

    Somebody said, why don't you go to **reddit** or **stack Overflow** to get an answer or improve you English?

    Well, I will do that next time.

    But I wonder know whether there is any post rule about language limit(you shouldn't use English, you can only use Chinese on this site?) on V2EX or it is just a morally hijacked.

    This is a question for learning, and it is not for arguments or catfights. Please take care of your words.

    The END.
    Supplement 2  ·  Dec 11, 2017
    谢谢所有的善意的指导,我会去 Stack Overflow 或者 Reddit 的.
    对于某些人说我态度不好,我不知道我那句话用得不好。

    我的初衷不是为了装逼,只要不嘲笑这一点,其他我都无所谓。
    35 replies    2018-01-09 23:25:51 +08:00
    flyingghost
        1
    flyingghost  
       Dec 11, 2017   ❤️ 10
    session 是一种意图,一种妄图在无状态的 HTTP 里标记每个 client 状态的意图。
    这个意图的实现需要 6 个组成步骤:
    1,server 生成标明 client 的标记。(用什么方式标明?例:session 对象及其 sessionID )
    2,把这个标记存储在 server 端。(存在哪里?例:磁盘文件)
    3,把这个标记发往 client。(通过什么方式发送?例:Set-Cookie 头)
    4,client 存储这份标记。(如何存储?例:Cookie 存储)
    5,client 下次请求的时候,携带这份标记。(如何确保自动携带?通过什么东西承载?例:Cookie 头)
    6,server 端根据标记去 2 里面找到对应的 client。

    session 是一种机制。
    而 redis/memcache 只是用来存储标记的位置而已,他们只负责第 2 点部分。
    shanechiu
        2
    shanechiu  
    OP
       Dec 11, 2017
    @flyingghost Well, I agree with you on session is an intention and it is also a mechanism. But, I wonder know who carries out the first step. A web server,like Nginx, Apache HTTP or others?
    dcll222
        3
    dcll222  
       Dec 11, 2017
    session 是数据, redis/memcached 是存储数据的手段
    leetom
        4
    leetom  
       Dec 11, 2017   ❤️ 1
    @shanechiu Web 服务器不负责生成,是你的应用生成的。没有 Session, 所有的 HTTP 功能都能正常工作,只是服务器不知道对方是谁了。甚至你可以自己通过 token 来模拟 session 的所有功能。

    另外,英语不好为啥不用中文呢 orz
    flyingghost
        5
    flyingghost  
       Dec 11, 2017
    @shanechiu 一般是应用服务器。例如:PHP、Tomcat 等。nginx 一般不管这事。
    Cooky
        6
    Cooky  
       Dec 11, 2017 via Android
    装老外 666
    shanechiu
        7
    shanechiu  
    OP
       Dec 11, 2017
    @leetom Well,I also know my English poor, and I am doing my best to improve it. Applying is a basic way to perfect my English, isn't it? But,thank you all the same.
    oott123
        8
    oott123  
       Dec 11, 2017   ❤️ 3
    如果楼主是想练习英文,可以考虑去 reddit 之类的英文社区逛逛。请你在达成“练习自己的英文水平”目的的同时,也考虑下这个社区其它人的感受,毕竟这是一个中文社区。更何况你在期望其他人给你回答,更应该站在别人的角度多多考虑一下。

    至于楼主的问题 1L 已经解释得十分清楚了。
    shanechiu
        9
    shanechiu  
    OP
       Dec 11, 2017
    @oott123 if you do not like it, just ignore it. Thanks all the same.
    oott123
        10
    oott123  
       Dec 11, 2017   ❤️ 2
    @shanechiu #9 并不是「我」不喜欢。
    事实上我对你或者这个帖子本身并没有什么特别的看法,只是在提醒你这样的行为在一个公共社区并不合适,以免你遗漏这一点。这是个公序良俗的问题。
    当然你听不听也随意,如果你不喜欢这种意见一样可以忽略我。
    shanechiu
        11
    shanechiu  
    OP
       Dec 11, 2017
    @oott123 That's fine.
    520671
        12
    520671  
       Dec 11, 2017
    Alternatively, we could also remind you to stop being an ignorant idiot.

    Thanks all the same.
    shanechiu
        13
    shanechiu  
    OP
       Dec 11, 2017
    @520671 Well,I wouldn't like to make a argument.
    520671
        14
    520671  
       Dec 11, 2017
    > Well,I wouldn't like to make a argument.
    ^[0]
    Oh sure you did. If you want to take a stance and ask others to be quiet for disagreeing with you, surely your actions speak louder than your words.

    [0] https://www.englishpage.com/articles/a-vs-an.htm
    shanechiu
        15
    shanechiu  
    OP
       Dec 11, 2017
    @520671 That does not make sense for me. The end. LOL
    orzfly
        16
    orzfly  
       Dec 11, 2017   ❤️ 3


    source: https://xkcd.com/1357/
    假如看不懂的话: http://xkcd.tw/1357
    shanechiu
        17
    shanechiu  
    OP
       Dec 11, 2017
    @orzfly got it.
    wxsm
        18
    wxsm  
       Dec 11, 2017   ❤️ 1
    小建议:如果你想更好地学习英文,请直接去英文社区,提问上 StackOverflow 嘛。不比在这里发个英文帖然后底下一堆中文回复的好吗?
    fml87
        19
    fml87  
       Dec 11, 2017   ❤️ 1
    英文标点后面要加空格
    kkzxak47
        20
    kkzxak47  
       Dec 11, 2017 via Android   ❤️ 1
    遇到 2 楼是你的福气,好好感谢他
    kkzxak47
        21
    kkzxak47  
       Dec 11, 2017 via Android
    也有客户端存储的 session,比如存在 cookie 里。
    session 实现机制五花八门,重要的是理解 session 的本质: 在一个没有上下文的环境里试图恢复上下文
    shanechiu
        22
    shanechiu  
    OP
       Dec 11, 2017 via Android
    @kkzxak47 yep,flyinghost is nice and patient.
    beastk
        23
    beastk  
       Dec 11, 2017 via iPhone
    楼主你要是中国人,那么请用中文,如果你是老外,我们一点意见都没有,还会夸赞你好学。谢谢。
    bxb100
        24
    bxb100  
       Dec 11, 2017 via Android
    你是询问别人,那么尊重被询问人的建议也是应该的,键盘侠路过
    shanechiu
        25
    shanechiu  
    OP
       Dec 11, 2017 via Android
    @bxb100 I agree with you.
    iVeego
        26
    iVeego  
       Dec 11, 2017
    @orzfly #16 网站很有趣,收藏了。感谢。
    Livid
        27
    Livid  
    MOD
    PRO
       Dec 11, 2017   ❤️ 1
    @oott123 这种 Chinglish 看着太辣眼睛了。已经降权这个账号 -8。
    iVeego
        28
    iVeego  
       Dec 11, 2017
    @Livid #27 哈哈哈,我还想回复楼主几个语法错误呢,不过看他回复 @520671 的态度,我觉得又没有必要了。
    flyico
        29
    flyico  
       Dec 11, 2017 via iPhone   ❤️ 1
    想练英文应该去 SO 或者 Reddit 在中文网站上用英文纯属装 B 而且只会越来越 Chinglish
    huangsw
        30
    huangsw  
       Dec 11, 2017   ❤️ 1
    心疼楼主 1s. The end. LOL
    shanechiu
        31
    shanechiu  
    OP
       Dec 11, 2017 via Android
    @Livid 所以,能请教一下吗?我该怎么转变我这种中式英语或者说中式思维了,因为确实学英语没多久,大概两个月吧?刚看了一些语法书,然后尝试着去造了句子.我也知道自己输入的不够,但是我的确想掌握英语,毕竟刚学的东西容易忘,如果要掌握的法就是用。我目前确实没有太多机会去给人写 email 或者直接沟通?我目前还没有找到比较好的方法,我能做的是造句。你如果你有比较好的方法,那么可以推荐给我吗?
    shanechiu
        32
    shanechiu  
    OP
       Dec 11, 2017 via Android
    @iVeego 我很好奇在你眼里我是什么态度。我的确不想争论跟他争论。
    shanechiu
        33
    shanechiu  
    OP
       Dec 11, 2017 via Android
    @flyico 你是对的,但是 stack overflow 的问题门槛很高。你知道的。
    Livid
        34
    Livid  
    MOD
    PRO
       Dec 11, 2017
    @shanechiu 去一个周围大部分人都只讲英语的环境。比如美国。
    mingyun
        35
    mingyun  
       Jan 9, 2018
    1 楼正解
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1389 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 518ms · UTC 17:03 · PVG 01:03 · LAX 10:03 · JFK 13:03
    ♥ Do have faith in what you're doing.