使用Node.js缓存数据库查询 [英] Caching database queries with Node.js

查看:165
本文介绍了使用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:

  1. ptarjan/node-cache
  2. tcs-de/nodecache
  3. vxtindia/node-cache
  4. mape/node-caching
  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.

现在还有 redis 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆