ptarjan / node-cache

A simple in-memory cache for nodejs
BSD 2-Clause "Simplified" License
1.59k stars 214 forks source link

max memory limit #77

Closed antonioaltamura closed 8 years ago

antonioaltamura commented 8 years ago

Hi, what do you think about add this feature? I mean just a simple way to control the cache grown.

ptarjan commented 8 years ago

This library isn't for volatile caches. If it was I would have written it in a way where every key knew how to populate itself and would just use the cache when RAM was available. Instead it is very much for persistant on-box caching.

If you are worried about memory limits, I'd recommend using performance.memory in Chrome and then doing things that are specific to your application on how to limit memory growth.

antonioaltamura commented 8 years ago

don't you think an unlimited hashmap growth may be also a security flaw? What's happen if I intentionally make thousands of different requests and let the hashmap grows in the order of magnitude of hundreds of MB in little time?