Caching database queries with Node.js

前端 未结 3 752
-上瘾入骨i
-上瘾入骨i 2021-01-04 11:52

Is there an implementation of database (mysql) query caching written purely in Node.js?

I\'m writing a Node web app and was planning on caching queries with memcache

相关标签:
3条回答
  • 2021-01-04 12:00

    I went ahead and wrote a caching solution for private use that stored the data in a shared object. This wasn't really query caching, it stores specific results instead of raw sql results ordered by hashes, but it kept what I needed in memory and was ridiculously easy to write.

    Since I originally asked this question a number of node caching solutions have emmerged:

    1. ptarjan/node-cache
    2. tcs-de/nodecache
    3. vxtindia/node-cache
    4. mape/node-caching

    I haven't used any of these but one of them might well be of use to someone else.

    There are now also redis and memcached clients for node.

    0 讨论(0)
  • 2021-01-04 12:08

    You can definitely implement something like this in node, and it could be an interesting project, but it depends on your needs. If you're just doing this for a hobby project, by all means, build a caching layer in node and try it out. Let us know how it goes!

    If this is for production use, then I would recommend sticking to the established caching layers (memcached, redis, etc) as they have already gone through all of the growing pains associated with building a scalable caching system.

    0 讨论(0)
  • 2021-01-04 12:21

    I have written a node.js module that performs MySQL query caching using memcached.

    The module is named Memento and is available at https://www.npmjs.com/package/memento-mysql

    Enjoy!

    0 讨论(0)
提交回复
热议问题