douxun7992 2014-04-10 21:14
浏览 79
已采纳

使用Gorilla会话自定义后端有什么优势?

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

  • 写回答

1条回答 默认 最新

  • drvxnivoqf17568697 2014-04-10 21:23
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决