{"_id":"@neophi/sieve-cache","_rev":"7-c5a92d2ad96baecd77b9688e58e27fb8","name":"@neophi/sieve-cache","dist-tags":{"latest":"1.5.0"},"versions":{"1.0.1":{"name":"@neophi/sieve-cache","version":"1.0.1","description":"Performant Map based cache using the SIEVE algorithm for eviction.","main":"dist/index.js","types":"./dist/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"engines":{"node":">=18"},"type":"module","scripts":{"clean":"rimraf dist","build":"tsc","build:test":"tsc --project tsconfig-test.json","pretest":"npm run clean && npm run build:test","test":"env NODE_ENV=test node --experimental-test-coverage --test dist/test","prepare":"npm run clean && npm run build"},"keywords":["sieve","cache"],"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"license":"MIT","devDependencies":{"@tsconfig/node20":"^20.1.2","@types/node":"^20.11.28","rimraf":"^5.0.5","typescript":"^5.4.2"},"_id":"@neophi/sieve-cache@1.0.1","gitHead":"55170615eb8346089a7d445019ce0122ebf407da","bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"homepage":"https://github.com/NeoPhi/sieve-cache#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-KuefKfONyCSvZNnKlvBw7xvRVlg47pZ4FC3chaN0BZ2jbnxCswLBFzLcF/8ppKvrAJ4uTtH1eYQMoMes2l+Y2Q==","shasum":"fedef1b9da2ab84455c3017ea957e42c0f146dd0","tarball":"https://registry.npmjs.org/@neophi/sieve-cache/-/sieve-cache-1.0.1.tgz","fileCount":5,"unpackedSize":12673,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@neophi%2fsieve-cache@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC940zaSN6ZbGSnLiQNK44cAX22PVmfkcoxOYJGLEnLxAiEA2PrbY5d4iK34kHApq+pqS49UEL/huTUvKqI40qucfW4="}]},"_npmUser":{"name":"danielr","email":"danielr@neophi.com"},"directories":{},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sieve-cache_1.0.1_1710526966597_0.541807866813476"},"_hasShrinkwrap":false},"1.1.0":{"name":"@neophi/sieve-cache","version":"1.1.0","description":"Performant Map based cache using the SIEVE algorithm for eviction.","main":"dist/index.js","types":"./dist/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"engines":{"node":">=18"},"type":"module","scripts":{"clean":"rimraf dist","build":"tsc","build:test":"tsc --project tsconfig-test.json","pretest":"npm run clean && npm run build:test","test":"env NODE_ENV=test node --experimental-test-coverage --test dist/test","prepare":"npm run clean && npm run build"},"keywords":["sieve","cache"],"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"license":"MIT","devDependencies":{"@tsconfig/node20":"^20.1.2","@types/node":"^20.11.28","rimraf":"^5.0.5","typescript":"^5.4.2"},"_id":"@neophi/sieve-cache@1.1.0","gitHead":"15d6e51cbfbc31b445040181db7b3fc1dbc19032","bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"homepage":"https://github.com/NeoPhi/sieve-cache#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-zSHqOSJm0ikhEnJmEg9VpAZ8PKrAqUJPnKmqh44oRQU0QGKWYSPYHKLnGJ2Y/COMLs7crDRgIjYUp2kfoZkYqw==","shasum":"35f2e05eecfa2423cff49c5ebfa835407c2e1e25","tarball":"https://registry.npmjs.org/@neophi/sieve-cache/-/sieve-cache-1.1.0.tgz","fileCount":5,"unpackedSize":13134,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@neophi%2fsieve-cache@1.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBImMChZsPMgDZDHVrSzh1wuZQMxfg+Tm7Eoy9aCmkR8AiEA1WYEjN2l79gkdEiv2L7OrpF5SvKJF/rHnAvFGDkcDuA="}]},"_npmUser":{"name":"danielr","email":"danielr@neophi.com"},"directories":{},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sieve-cache_1.1.0_1711040370769_0.6753303645039137"},"_hasShrinkwrap":false},"1.2.0":{"name":"@neophi/sieve-cache","version":"1.2.0","description":"Performant Map based cache using the SIEVE algorithm for eviction.","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"types":"./dist/mjs/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"engines":{"node":">=18"},"scripts":{"clean":"rimraf dist","build":"tsc && tsc --project tsconfig-cjs.json","postbuild":"./tools/packages.sh","build:test":"tsc --project tsconfig-test.json","pretest":"npm run clean && npm run build:test","test":"env NODE_ENV=test node --experimental-test-coverage --test dist/test","prepare":"npm run clean && npm run build"},"keywords":["sieve","cache"],"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"license":"MIT","devDependencies":{"@tsconfig/node20":"^20.1.2","@types/node":"^20.11.28","rimraf":"^5.0.5","typescript":"^5.4.2"},"_id":"@neophi/sieve-cache@1.2.0","gitHead":"5a8683bb3ced0b478f7adc6b28ce3c3c2f4ad3c7","bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"homepage":"https://github.com/NeoPhi/sieve-cache#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-6UCYun8MOJqPwspL1JRM3jlasRl/QUp5I8TRzFu4Tlwq0kAGuqI1ejqkgI1IRW97RoHeLfGbU4R9E8vNHgOL6g==","shasum":"6b591dcef73d254b2d953498891110bcfcff6c24","tarball":"https://registry.npmjs.org/@neophi/sieve-cache/-/sieve-cache-1.2.0.tgz","fileCount":9,"unpackedSize":22615,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@neophi%2fsieve-cache@1.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDF6YqDLmjYWhlV00HeM35D8oXaiBRJ9Hu8rnugpBPUcAIhAMBGt8VaFKAq24toTq4qU7LJfUsevCMjlDA60tdtQ8Kd"}]},"_npmUser":{"name":"danielr","email":"danielr@neophi.com"},"directories":{},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sieve-cache_1.2.0_1711489409932_0.9837635566217189"},"_hasShrinkwrap":false},"1.3.0":{"name":"@neophi/sieve-cache","version":"1.3.0","description":"Performant Map based cache using the SIEVE algorithm for eviction.","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"types":"./dist/mjs/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"engines":{"node":">=18"},"scripts":{"clean":"rimraf dist","build":"tsc && tsc --project tsconfig-cjs.json","postbuild":"./tools/packages.sh","build:test":"tsc --project tsconfig-test.json","pretest":"npm run clean && npm run build:test","test":"env NODE_ENV=test node --experimental-test-coverage --test dist/test","prepare":"npm run clean && npm run build"},"keywords":["sieve","cache"],"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"license":"MIT","devDependencies":{"@tsconfig/node20":"^20.1.2","@types/node":"^20.11.28","rimraf":"^5.0.5","typescript":"^5.4.2"},"_id":"@neophi/sieve-cache@1.3.0","gitHead":"a2e57c1fa57d8a2c38ed3974e7d4f1c5516ad99a","bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"homepage":"https://github.com/NeoPhi/sieve-cache#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-DKcjFzD4kznmyH4iRjXGz34XbxA0f2pbBGhA9+nDOGMeCfQqHqth6wLKCs44/RdOpvkbcPlqMj4FGBonzNc2MA==","shasum":"bc5549177ed0ca07357c7f7f544add5183560ba7","tarball":"https://registry.npmjs.org/@neophi/sieve-cache/-/sieve-cache-1.3.0.tgz","fileCount":9,"unpackedSize":22430,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@neophi%2fsieve-cache@1.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDO6gyJLcz/n6s0Gtrf7alM/pOvCpdWed+twN5c7DnkFQIgSpDka+qnr5W3m3DsCRHfTgAL97BvSez8JZJ2ZleVK+s="}]},"_npmUser":{"name":"danielr","email":"danielr@neophi.com"},"directories":{},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sieve-cache_1.3.0_1711668819352_0.2725480086982548"},"_hasShrinkwrap":false},"1.4.0":{"name":"@neophi/sieve-cache","version":"1.4.0","description":"Performant Map based cache using the SIEVE algorithm for eviction.","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"types":"./dist/mjs/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"engines":{"node":">=18"},"scripts":{"clean":"rimraf dist","build":"tsc && tsc --project tsconfig-cjs.json","postbuild":"./tools/packages.sh","build:test":"tsc --project tsconfig-test.json","pretest":"npm run clean && npm run build:test","test":"env NODE_ENV=test node --experimental-test-coverage --test dist/test","prepare":"npm run clean && npm run build"},"keywords":["sieve","cache"],"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"license":"MIT","devDependencies":{"@tsconfig/node20":"^20.1.2","@types/node":"^20.11.28","rimraf":"^5.0.5","typescript":"^5.4.2"},"_id":"@neophi/sieve-cache@1.4.0","gitHead":"cdb70d9d991acf38bda2de2ee0b0091c2169cf03","bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"homepage":"https://github.com/NeoPhi/sieve-cache#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-RR6EluFZC+duJbUs+PHj5xBH77BAApCIMXgxGXHrcvlGv+sF4AYETVxQcfOiKzwgL0iuntvV7t1Jojqmj0IDZQ==","shasum":"2783bc032922ab91102ee1d6a0668d3f5692b66e","tarball":"https://registry.npmjs.org/@neophi/sieve-cache/-/sieve-cache-1.4.0.tgz","fileCount":9,"unpackedSize":22514,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@neophi%2fsieve-cache@1.4.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG5CBxtqUOdhwFOkehQ9WMndMEcQYoP3aj4LXFHYRTFQAiB/1uxanHpmOLDdEfm8d6kdPoSApGo28bKNLfRzTOAOAQ=="}]},"_npmUser":{"name":"danielr","email":"danielr@neophi.com"},"directories":{},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sieve-cache_1.4.0_1711765827970_0.6654577330079612"},"_hasShrinkwrap":false},"1.5.0":{"name":"@neophi/sieve-cache","version":"1.5.0","description":"Performant Map based cache using the SIEVE algorithm for eviction.","main":"dist/cjs/index.js","module":"dist/mjs/index.js","exports":{".":{"import":"./dist/mjs/index.js","require":"./dist/cjs/index.js"}},"types":"./dist/mjs/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"engines":{"node":">=18"},"scripts":{"clean":"rimraf dist","build":"tsc && tsc --project tsconfig-cjs.json","postbuild":"./tools/packages.sh","build:test":"tsc --project tsconfig-test.json","pretest":"npm run clean && npm run build:test","test":"env NODE_ENV=test node --experimental-test-coverage --test dist/test","prepare":"npm run clean && npm run build"},"keywords":["sieve","cache"],"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"license":"MIT","devDependencies":{"@tsconfig/node20":"^20.1.2","@types/node":"^20.11.28","rimraf":"^5.0.5","typescript":"^5.4.2"},"_id":"@neophi/sieve-cache@1.5.0","gitHead":"63b160c9cf62d1c584ad1c6151d815ef831589c1","bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"homepage":"https://github.com/NeoPhi/sieve-cache#readme","_nodeVersion":"18.19.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-9T3nD5q51X1d4QYW6vouKW9hBSb2Tb/wB/2XoTr4oP5SCGtp3a7aTHHewQFylred1B21/Bhev6gy4x01FPBcbQ==","shasum":"743182f4b195482ff8707a6725f2f098ef3ab634","tarball":"https://registry.npmjs.org/@neophi/sieve-cache/-/sieve-cache-1.5.0.tgz","fileCount":9,"unpackedSize":24202,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@neophi%2fsieve-cache@1.5.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuuRfC7PUKstE263OLPucRZswzJ/oAhIamXbM+bWtXwwIhAOqtAqhZ3enXgI+EawsxQ8bkINeXMVT2txfpr954pkT4"}]},"_npmUser":{"name":"danielr","email":"danielr@neophi.com"},"directories":{},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sieve-cache_1.5.0_1711980976260_0.15689668528304734"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-15T18:13:46.081Z","1.0.0":"2024-03-15T18:13:46.352Z","modified":"2024-04-01T14:16:16.834Z","1.0.1":"2024-03-15T18:22:46.746Z","1.1.0":"2024-03-21T16:59:30.938Z","1.2.0":"2024-03-26T21:43:30.139Z","1.3.0":"2024-03-28T23:33:39.509Z","1.4.0":"2024-03-30T02:30:28.132Z","1.5.0":"2024-04-01T14:16:16.464Z"},"maintainers":[{"name":"danielr","email":"danielr@neophi.com"},{"name":"neophi-npm","email":"neophi@gmail.com"}],"description":"Performant Map based cache using the SIEVE algorithm for eviction.","homepage":"https://github.com/NeoPhi/sieve-cache#readme","keywords":["sieve","cache"],"repository":{"type":"git","url":"git://github.com/NeoPhi/sieve-cache.git"},"author":{"name":"Daniel Rinehart","email":"danielr@neophi.com"},"bugs":{"url":"https://github.com/NeoPhi/sieve-cache/issues"},"license":"MIT","readme":"# sieve-cache\n\n[A performant implementation](https://github.com/NeoPhi/cache-playground) of the [SIEVE caching algorithm](https://sievecache.com) that implements [Map properties and methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#instance_properties) designed for Node.js 20+.\n\n## Installation\n\n```bash\nnpm install @neophi/sieve-cache --save\n```\n\n## Usage\n\n```js\nimport { SieveCache } from \"@neophi/sieve-cache\";\n\nconst sieveCache = new SieveCache<string, string>(2);\nsieveCache.set(\"key\", \"value\");\n// \"value\"\nsieveCache.get(\"key\");\nsieveCache.set(\"key2\", \"value2\");\n// triggers eviction via SIEVE algorithm\nsieveCache.set(\"key3\", \"value3\");\n// false\nsieveCache.has(\"key2\");\n```\n\nThe API exposes the JS [Map properties and methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#instance_properties).\n\n## Options\n\n```\nconstructor(maxSize: number, options: Partial<SieveCacheOptions<K, V>> = {})\n```\n\nThe `maxSize` of the cache must be at least 1 and less than 4,294,967,295.\n\nThe `existingSetBehavior` option changes the behavior of the SIEVE `visited` state when updating a key that already exists in the Map. The default is `ExistingSetBehavior.VISITED_SKIP` which means the existing visited state is not modified.\n\nThe `evictHook` option is a function `(key: K, value: V) => void` that can be configured to be called with the details of the evicted item after the cache has been updated.\n\n```js\nimport { SieveCache, ExistingSetBehavior } from \"@neophi/sieve-cache\";\n\nconst sieveCache = new SieveCache<string, string>(2, {\n  existingSetBehavior: ExistingSetBehavior.VISITED_TRUE,\n  evictHook: (key, value) => { console.log(`Evicted ${key} => ${value}`); }\n});\n```\n\n## Performance\n\nAlways benchmark your specific use case since many runtime, key type, and object type differences can impact the performance of an implementation. With that said this implementation compares favorably to established libraries such as [lru-cache](https://github.com/isaacs/node-lru-cache) and [mnemonist](https://github.com/yomguithereal/mnemonist). For an extensive benchmark see [cache-playground](https://github.com/NeoPhi/cache-playground).\n\n## Credits\n\nThis implementation was inspired by [Implementing an efficient LRU cache in JavaScript](https://yomguithereal.github.io/posts/lru-cache).\n\n## Contributing\n\nEveryone interacting with this project is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n\n## License\n\nReleased under the [MIT License](LICENSE).\n","readmeFilename":"README.md"}