使用Node.js缓存数据库查询

编程入门 行业动态 更新时间:2024-10-27 18:23:45
本文介绍了使用Node.js缓存数据库查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有纯粹用Node.js编写的数据库(mysql)查询缓存实现?

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

我正在编写一个Node Web应用程序,并计划使用memcached缓存查询,但是考虑到这一点,我意识到有可能改为通过单独的Node.js层进行缓存

I'm writing a Node web app and was planning on caching queries with memcached, but while considering this I realised it's probably possible to do the caching through a separate Node.js layer instead

说明:

您可以通过单独端口上的节点服务器查询数据库,从可用的内存中返回数据,然后将其加载到不可用的内存中.

You could query the database through a node server on a separate port, returning data from memory where available and loading it into memory where it isn't.

任何人都知道在散列数组的返回速度方面,Node.js将如何与memcache进行比较?这是白日梦还是我应该看的东西?

Anyone know how Node.js would compare to memcache in terms of return speed on hashed arrays? Is this a pipe-dream or something I should look at?

推荐答案

我继续写了一个供个人使用的缓存解决方案,该解决方案将数据存储在共享对象中.这并不是真正的查询缓存,它存储特定的结果,而不是按哈希排序的原始sql结果,但是它将我所需的内容保留在内存中,并且易于编写.

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:

  • ptarjan/node-cache
  • tcs-de/nodecache
  • vxtindia/node-cache
  • mape/node-caching
  • ptarjan/node-cache
  • tcs-de/nodecache
  • vxtindia/node-cache
  • mape/node-caching
  • 我没有使用过任何一个,但是其中一个可能对其他人有用.

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

    现在还有 redis 和内存缓存客户端.

    更多推荐

    使用Node.js缓存数据库查询

    本文发布于:2023-10-19 00:07:47,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1505830.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:缓存   数据库查询   Node   js

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!