{"id":16760352,"url":"https://github.com/roccomuso/memorystore","last_synced_at":"2025-05-16T08:05:58.127Z","repository":{"id":22901462,"uuid":"97607157","full_name":"roccomuso/memorystore","owner":"roccomuso","description":"express-session full featured MemoryStore layer without leaks!","archived":false,"fork":false,"pushed_at":"2024-06-16T15:03:12.000Z","size":77,"stargazers_count":121,"open_issues_count":6,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T19:25:23.952Z","etag":null,"topics":["cache","express","memory","memorystore","noleak","session","sessions"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roccomuso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-18T14:19:31.000Z","updated_at":"2025-02-26T23:45:35.000Z","dependencies_parsed_at":"2024-10-18T23:10:05.923Z","dependency_job_id":null,"html_url":"https://github.com/roccomuso/memorystore","commit_stats":{"total_commits":83,"total_committers":10,"mean_commits":8.3,"dds":0.3373493975903614,"last_synced_commit":"b1e4c771dcc681117e785ac6ad6184f5109edf9b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fmemorystore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fmemorystore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fmemorystore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roccomuso%2Fmemorystore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roccomuso","download_url":"https://codeload.github.com/roccomuso/memorystore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","express","memory","memorystore","noleak","session","sessions"],"created_at":"2024-10-13T04:23:13.803Z","updated_at":"2025-05-16T08:05:53.116Z","avatar_url":"https://github.com/roccomuso.png","language":"JavaScript","readme":"# memorystore [![NPM Version](https://img.shields.io/npm/v/memorystore.svg)](https://www.npmjs.com/package/memorystore) ![node](https://img.shields.io/node/v/memorystore.svg) [![Build Status](https://travis-ci.org/roccomuso/memorystore.svg?branch=master)](https://travis-ci.org/roccomuso/memorystore) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n\u003e express-session full featured `MemoryStore` module without leaks!\n\nA session store implementation for Express using [lru-cache](https://github.com/isaacs/node-lru-cache).\n\nBecause the default `MemoryStore` for [express-session](https://github.com/expressjs/session) will lead to a memory leak due to it haven't a suitable way to make them expire.\n\nThe sessions are still stored in memory, so they're not shared with other processes or services.\n\n## Setup\n\n    $ npm install express-session memorystore\n\nPass the `express-session` store into `memorystore` to create a `MemoryStore` constructor.\n\n```javascript\nconst session = require('express-session')\nconst MemoryStore = require('memorystore')(session)\n\napp.use(session({\n    cookie: { maxAge: 86400000 },\n    store: new MemoryStore({\n      checkPeriod: 86400000 // prune expired entries every 24h\n    }),\n    resave: false,\n    secret: 'keyboard cat'\n}))\n```\n\n## Options\n\n* `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.\n* `max` The maximum size of the cache, checked by applying the length\n  function to all values in the cache.  It defaults to `Infinity`.\n* `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) =\u003e number`.\n* `dispose` Function that is called on sessions when they are dropped\n  from the cache.  This can be handy if you want to close file\n  descriptors or do other cleanup tasks when sessions are no longer\n  accessible.  Called with `key, value`.  It's called *before*\n  actually removing the item from the internal cache, so if you want\n  to immediately put it back in, you'll have to do that in a\n  `nextTick` or `setTimeout` callback or it won't do anything.\n* `stale` By default, if you set a `maxAge`, it'll only actually pull\n  stale items out of the cache when you `get(key)`.  (That is, it's\n  not pre-emptively doing a `setTimeout` or anything.)  If you set\n  `stale:true`, it'll return the stale value before deleting it.  If\n  you don't set this, then it'll return `undefined` when you try to\n  get a stale entry, as if it had already been deleted.\n* `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.\n* `serializer` An object containing `stringify` and `parse` methods compatible with Javascript's `JSON` to override the serializer used.\n\n## Methods\n\n`memorystore` implements all the **required**, **recommended** and **optional** methods of the [express-session](https://github.com/expressjs/session#session-store-implementation) store. Plus a few more:\n\n- `startInterval()` and `stopInterval()` methods to start/clear the automatic check for expired.\n\n- `prune()` that you can use to manually remove only the expired entries from the store.\n\n## Debug\n\nTo enable debug set the env var `DEBUG=memorystore`\n\n# Author\n\nRocco Musolino ([@roccomuso](https://twitter.com/roccomuso))\n\n# License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froccomuso%2Fmemorystore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froccomuso%2Fmemorystore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froccomuso%2Fmemorystore/lists"}