All Projects → roccomuso → Memorystore

roccomuso / Memorystore

Licence: mit
express-session full featured MemoryStore layer without leaks!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Memorystore

Cash
HTTP response caching for Koa. Supports Redis, in-memory store, and more!
Stars: ✭ 122 (+54.43%)
Mutual labels:  cache, memory, session, sessions
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+1111.39%)
Mutual labels:  cache, express, memory
Django Qsessions
Extended session backends for Django (Sessions store IP, User Agent, and foreign key to User)
Stars: ✭ 64 (-18.99%)
Mutual labels:  cache, session, sessions
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+22649.37%)
Mutual labels:  cache, session
bk flutter image
flutter image,降低内存使用
Stars: ✭ 32 (-59.49%)
Mutual labels:  memory, cache
sessionx
Go's web session library.
Stars: ✭ 75 (-5.06%)
Mutual labels:  session, sessions
Gf
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.
Stars: ✭ 6,501 (+8129.11%)
Mutual labels:  cache, session
Many People Blog
🎈基于vue+node+mysql的多人博客,带后台管理系统。支持:登陆/注册,留言,评论/回复,点赞,记录浏览数量,带有相册功能,内容丰富,当然也可以发表文章。欢迎使用!
Stars: ✭ 300 (+279.75%)
Mutual labels:  express, session
Gocache
☔️ A complete Go cache library that brings you multiple ways of managing your caches
Stars: ✭ 775 (+881.01%)
Mutual labels:  cache, memory
Scs
HTTP Session Management for Go
Stars: ✭ 847 (+972.15%)
Mutual labels:  session, sessions
Outputcache
Cache api responses using Redis, Memcached or any cache provider for NodeJS
Stars: ✭ 9 (-88.61%)
Mutual labels:  cache, express
echo-mw
统一移到hb-go/echo-web ☞
Stars: ✭ 17 (-78.48%)
Mutual labels:  cache, session
Thinkgo
A lightweight MVC framework written in Go (Golang).
Stars: ✭ 184 (+132.91%)
Mutual labels:  cache, session
Express Mysql Session
A MySQL session store for the express framework in node
Stars: ✭ 268 (+239.24%)
Mutual labels:  express, sessions
Go Cache
This project encapsulates multiple db servers, redis、ledis、memcache、file、memory、nosql、postgresql
Stars: ✭ 143 (+81.01%)
Mutual labels:  cache, memory
Koa Redis
Redis storage for Koa session middleware/cache with Sentinel and Cluster support
Stars: ✭ 324 (+310.13%)
Mutual labels:  cache, session
Connect Session Sequelize
Sequelize SessionStore for Express/Connect
Stars: ✭ 179 (+126.58%)
Mutual labels:  express, sessions
Node Cache
a node internal (in-memory) caching module
Stars: ✭ 1,660 (+2001.27%)
Mutual labels:  cache, memory
Vue express session nodb
这是一个带有express session验证的vue项目,其中server适用于其他任何前端框架,开发者可以根据自己的需求进行更改;另外session存储不涉及数据库存储,使用的是内存存储。
Stars: ✭ 24 (-69.62%)
Mutual labels:  express, session
Sst Elements
SST Architectural Simulation Components and Libraries
Stars: ✭ 36 (-54.43%)
Mutual labels:  cache, memory

memorystore NPM Version node Build Status JavaScript Style Guide

express-session full featured MemoryStore module without leaks!

A session store implementation for Express using lru-cache.

Because the default MemoryStore for express-session will lead to a memory leak due to it haven't a suitable way to make them expire.

The sessions are still stored in memory, so they're not shared with other processes or services.

Setup

$ npm install express-session memorystore

Pass the express-session store into memorystore to create a MemoryStore constructor.

var session = require('express-session')
var MemoryStore = require('memorystore')(session)

app.use(session({
    cookie: { maxAge: 86400000 },
    store: new MemoryStore({
      checkPeriod: 86400000 // prune expired entries every 24h
    }),
    resave: false,
    secret: 'keyboard cat'
}))

Options

  • checkPeriod Define how long MemoryStore will check for expired. The period is in ms. The automatic check is disabled by default! Not setting this is kind of silly, since that's the whole purpose of this lib.
  • max The maximum size of the cache, checked by applying the length function to all values in the cache. It defaults to Infinity.
  • ttl Session TTL (expiration) in milliseconds. Defaults to session.maxAge (if set), or one day. This may also be set to a function of the form (options, sess, sessionID) => number.
  • dispose Function that is called on sessions when they are dropped from the cache. This can be handy if you want to close file descriptors or do other cleanup tasks when sessions are no longer accessible. Called with key, value. It's called before actually removing the item from the internal cache, so if you want to immediately put it back in, you'll have to do that in a nextTick or setTimeout callback or it won't do anything.
  • stale By default, if you set a maxAge, it'll only actually pull stale items out of the cache when you get(key). (That is, it's not pre-emptively doing a setTimeout or anything.) If you set stale:true, it'll return the stale value before deleting it. If you don't set this, then it'll return undefined when you try to get a stale entry, as if it had already been deleted.
  • noDisposeOnSet By default, if you set a dispose() method, then it'll be called whenever a set() operation overwrites an existing key. If you set this option, dispose() will only be called when a key falls out of the cache, not when it is overwritten.
  • serializer An object containing stringify and parse methods compatible with Javascript's JSON to override the serializer used.

Methods

memorystore implements all the required, recommended and optional methods of the express-session store. Plus a few more:

  • startInterval() and stopInterval() methods to start/clear the automatic check for expired.

  • prune() that you can use to manually remove only the expired entries from the store.

Debug

To enable debug set the env var DEBUG=memorystore

Author

Rocco Musolino (@roccomuso)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].