ptarjan / node-cache

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

Allow importing and exporting to JSON #83

Closed cooperka closed 7 years ago

cooperka commented 7 years ago

Awesome library, love the unit tests! I'm using it for caching web response data in a mobile app, and I find import/export to be valuable for saving to disk and restoring the cache later (for example, if you kill the app and then open it again, restore the offline data in case there's no internet anymore).

exportJson = function()

importJson = function(json: string, options: { skipDuplicates: boolean })

katzgrau commented 7 years ago

I was going to submit a PR for the same thing — I think this would be extremely helpful.

I have an app that relies heavily on memory-cache, and deploys wipe the cache, obviously.

I'm also sure that some apps running under supervisor or nodemon occasionally crash on some unexpected data, and could use this to keep things moving along smoothly.

cooperka commented 7 years ago

@ptarjan is this something you'd consider merging? Let me know if there's anything I can improve.

ptarjan commented 7 years ago

Yeah this sounds reasonable. I might debate on the names and API format once I see it but the overall shape seems broadly useful.

On Mon, Feb 27, 2017 at 1:20 PM Kevin Cooper notifications@github.com wrote:

@ptarjan https://github.com/ptarjan is this something you'd consider merging? Let me know if there's anything I can improve.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ptarjan/node-cache/pull/83#issuecomment-282857157, or mute the thread https://github.com/notifications/unsubscribe-auth/AACcz7ANhU1XA0V19xwgJCoSDK-JyKyyks5rgz43gaJpZM4MCVAu .

katzgrau commented 7 years ago

Sonic Tapping Foot

Just kidding, but any potential ETA?

cooperka commented 7 years ago

@ptarjan thanks for the feedback, it's updated now.

cooperka commented 7 years ago

@ptarjan ping :)

sebyddd commented 7 years ago

👍

ptarjan commented 7 years ago

Sorry to ask this, but https://github.com/ptarjan/node-cache/pull/85 submitted before you. Can you rebase on it and match the style they introduced? Thanks.

cooperka commented 7 years ago

@ptarjan done!