使用Gorilla会话自定义后端的优点是什么? [英] What is the advantage of using Gorilla sessions custom backend?

查看:157
本文介绍了使用Gorilla会话自定义后端的优点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Redis进行会话管理。

但是我无法弄清楚使用Redis作为Gorilla会话包的自定义后端直接使用它的优势是什么?



链接到Gorilla会话包: http:// www .golillatoolkit.org / pkg / sessions

解决方案

Gorilla会话提供了连接会话存储系统的方法管理提供您坚持提供的界面。目前,他们给你两个开箱即用的商店。一个是文件系统商店,它遵守简单地存储和在服务器的文件系统上检索基于会话的数据。另外一个选项是 CookieStore ,可以读取和写入构建的浏览器使用其他方式完成同样的事情。



Gorilla会话与Redis无关,但知道这一点,您可以轻松使用自己的会话存储与大猩猩提供您建立坚持大猩猩会议的RedisStore 商店界面一>。这完全取决于您的能力以及您在会话存储系统中寻找的内容。大猩猩基本上为您提供了两种开箱即用的选择,并提供了适合您的应用的自己的选择。

另外,如果您确实需要构建一个RedisStore,与Gorilla Sessions合作考虑将其开源,因为它对Go社区来说是一个很好的补充。



您必须评估您的应用程序的需求和性能需求找出要使用的存储系统。为什么Redis可能有意义?那么,如果你正在构建一个应用程序,该应用程序需要进行大量的写入/修改,并且这些数据需要持续存在,否则只要正确使用它,Redis就可以帮助您扩展应用程序。如果你知道自己在做什么,那么Redis支持的会话将表现的非常好。

最后一点,如果你涉及Redis,可以考虑使用这个精彩的Go包:
Redigo 作为您的Redis客户端库。


I want to use Redis for session management.
But I can't figure out what the advantage is of using Redis as a custom back-end for Gorilla sessions package over using it directly?

link to the Gorilla session package: http://www.gorillatoolkit.org/pkg/sessions

解决方案

Gorilla sessions provides a means to wire up a storage system for session management provided you adhere to the interface provided. Currently, they give you two stores out of the box. One is a FilesystemStore that adheres to the interface that simply stores and retrieves session based data on the server's filesystem. The CookieStore as another option, reads and writes to the browsers built-in cookie system to accomplish the same thing using another means.

Gorilla sessions really has nothing to do with Redis, but knowing this, you can easily use your own session storage with Gorilla provided you build a RedisStore that adheres to the Gorilla sessions Store interface. It really all depends on your capability and what you are looking for in a session store system. Gorilla basically gives you two options out of the box with an option for providing your own that suits your app.

Also, if you do get around to building a RedisStore that can work with Gorilla Sessions consider making it open-source since it would be a great addition to the Go community.

You have to evaluate the needs and performance requirements of your app to figure out which storage system to use. Why does Redis possibly make sense? Well if you are building an app that does heavy writes/modifications and this data needs to persist Redis is well known to help you scale your app so long as you utilize it properly. A Redis backed session will perform really well if you know what you are doing.

Last point, should you get Redis involved consider using this wonderful Go package: Redigo as your Redis client library.

这篇关于使用Gorilla会话自定义后端的优点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆