ptarjan / node-cache

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

cache key length limit #107

Open dongmei761 opened 6 years ago

dongmei761 commented 6 years ago

I'm wondering if the cache key has a length limit? Is it the same with the length limit of String on V8? Will these long keys impact the performance?

danielway commented 5 years ago

Hi there @dongmei761.

It seems that your guess is correct; key length will be limited by string sizes for the environment. The standard answer is 2^27 characters. [1]

Regarding performance impacts, once again there are differences environment-to-environment. It seems most browsers will place keys into a hash-table making their lookup efficient and not dependent on key length. [2]

References: [1] https://stackoverflow.com/a/28841863 [2] https://stackoverflow.com/a/13940271