Git Product home page Git Product logo

session's Introduction

设计思路

Session 接口设计

  • Set()
  • Get()
  • Del()
  • Save() //session 存储,redis 的实现延迟加载

SessionMgr 接口设计

  • init() //初始化,加载 redis 地址
  • CreatSession() //创建一个新的 session
  • GetSession() //通过 sessionID 获取对应的 session 对象

MemorySession 设计

  • 定义 MemorySession 对象(字段:sessionID;存 kv 的 map,读写锁)
  • 构造函数 为了获取对象
  • Set()
  • Get()
  • Del()
  • Save()

MemorySessionMgr 设计

  • 定义 MemorySessionMgr 对象(字段:存放所有 session 的 map;读写锁)
  • 构造函数
  • init()
  • CreatSession() //创建一个新的 session
  • GetSession() //通过 sessionID 获取对应的 session 对象

RedisSession 设计

  • 定义 RedisSession 对象(字段:sessionID;存 kv 的 map,读写锁;redis 连接池;记录内存中 map 是否被修改的标记)
  • 构造函数 为了获取对象
  • Set() //将 session 存到内存中的 map
  • Get() //取数据;实现延迟加载
  • Del()
  • Save()// 把 session 存到 redis

RedisSessionMgr 设计

  • 定义 RedisSessionMgr 对象(字段:redis 地址、redis 密码;连接池、存放所有 session 的 map;读写锁)
  • 构造函数
  • init()
  • CreatSession()
  • GetSession()

image-20200507221712326

session's People

Contributors

wzbwzt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.