简体   繁体   English

LAMP开发人员如何开始使用Redis / Node.js解决方案?

[英]How does a LAMP developer get started using a Redis/Node.js Solution?

I come from the cliche land of PHP and MySQL on Dreamhost. 我来自Dreamhost上PHP和MySQL的陈词滥调。 BUT! 但! I am also a javascript jenie and I've been dying to get on the Node.js train. 我也是一个javascript jenie,我一直渴望上Node.js火车。 In my reading I've discovered inadvertently a NoSQL solution called Redis! 在我的阅读中,我无意中发现了一个名为Redis的NoSQL解决方案!

With my shared web host and limited server experience (I know how to install Linux on one of my old dell's and do some basic server admin) how can I get started using Redis and Node.js? 凭借我的共享Web主机和有限的服务器体验(我知道如何在我的旧dell上安装Linux并执行一些基本的服务器管理员)如何开始使用Redis和Node.js? and the next best question is -- what does one even use Redis for? 而下一个最好的问题是 - 甚至使用Redis的用途是什么? What situation would Redis be better suited than MySQL? Redis比MySQL更适合什么情况? And does Node.js remove the necessity for Apache? Node.js是否删除了Apache的必要性? If so why do developers recommend using NGINX server? 如果是这样,为什么开发人员建议使用NGINX服务器?

Lots of questions but there doesnt seem to be a solid source out there with this info all in one place! 很多问题,但似乎没有一个坚实的来源,这些信息都在一个地方!

Thanks again for your guidance and feedback! 再次感谢您的指导和反馈!

NoSQL is just an inadequate buzz word. NoSQL只是一个不够热门的词汇。

I'll attempt to answer the latter part of the question. 我将尝试回答问题的后半部分。

Redis is a key-value store database system. Redis是一个键值存储数据库系统。 Speed is its primary objective, so most of its use comes from event driven implementations (as it goes over in its reddit tutorial). 速度是它的主要目标,因此它的大部分用途来自事件驱动的实现(因为它在reddit教程中已经过时)。

It excels at areas like logging, message transactions, and other reactive processes. 它擅长于日志记录,消息事务和其他反应过程等领域。

Node.js on the other hand is mainly for independent HTTP transactions. 另一方面,Node.js主要用于独立的HTTP事务。 It is basically used to serve content (much like a web server, but Node.js really wouldn't be necessarily public facing) very fast which makes it useful for backend business logic applications. 它基本上用于提供内容(很像Web服务器,但Node.js确实不一定是公开的)非常快,这使得它对后端业务逻辑应用程序很有用。

For example, having a C program calculate stock values and having Node.js serve the content for another internal application to retrieve or using Node.js to serve a web page one is developing so one's coworkers can view it internally. 例如,让C程序计算股票价值并让Node.js为另一个内部应用程序提供内容,以便检索或使用Node.js来提供网页,这样一个人正在开发,这样一个人的同事就可以在内部查看它。

It really excels as a middleman between applications. 它作为应用程序之间的中间人真的很擅长。

Redis Redis的

Redis is an in-memory datastore : All your data are stored in the memory meaning that a huge database means huge memory usage, but with really fast access and lookup. Redis是一个内存数据存储区:所有数据都存储在内存中,这意味着庞大的数据库意味着大量的内存使用,但具有非常快速的访问和查找。

It is also a key-value store : You don't have any realtionships, or queries to retrieve your data. 它也是一个键值存储:您没有任何实现或查询来检索您的数据。 You can only set a key value pair, and retreive it by its id. 您只能设置键值对,并通过其ID进行检索。 (Redis also provides useful types such as sets and hashes). (Redis还提供有用的类型,例如集合和散列)。

These particularities makes Redis really well suited for storing sessions in a web application, creating indexes on a database, handling real-time data like analytics. 这些特性使Redis非常适合在Web应用程序中存储会话,在数据库上创建索引,处理分析等实时数据。

So if you need something that will "replace" MySQL for storing your basic application models I suggest you try something like MongoDB, Riak or CouchDB that are document store. 因此,如果您需要一些能够“替换”MySQL以存储基本应用程序模型的东西,我建议您尝试使用MongoDB,Riak或CouchDB作为文档存储。 Document stores manages your data as something analogous to JSON objects (I know it's a huge shortcut). 文档存储管理您的数据类似于JSON对象(我知道它是一个巨大的捷径)。

Read this article if you want to know more about popular nosql databases . 如果您想了解有关流行的nosql数据库的更多信息,请阅读本文。

Node.js Node.js的

Node.js provides asynchrous I/O for the V8 JavaScript engine. Node.js为V8 JavaScript引擎提供异步I / O. When you run a node server, it listens on a port on your machine (eg 3000). 运行节点服务器时,它会侦听计算机上的端口(例如3000)。 It does not do any sort of Domain name resolution and Virtual Host handling so you have to use a http server with a proxy such as Apache or nginx. 它不执行任何类型的域名解析和虚拟主机处理,因此您必须使用具有Apache或nginx等代理的http服务器。

Choosing over nginx in production is a matter of performance, and I find it easier to use. 在生产中选择nginx是性能问题,我发现它更容易使用。 But I suggest you use the one you're the most comfortable with. 但我建议你使用你最舒服的那个。

To get started with it just install them and start playing with it. 要开始使用它,只需安装它们并开始使用它。 HowToNode HowToNode

You can get a free plan from https://redistogo.com/ - it is a hosted redis database instance. 您可以从https://redistogo.com/获得免费计划 - 它是托管的redis数据库实例。

Quick intro to redis data types and basic commands is available here - http://redis.io/topics/data-types-intro . 有关redis数据类型和基本命令的快速介绍,请访问http://redis.io/topics/data-types-intro

A good comparison of when to use what is here - http://playbook.thoughtbot.com/choosing-platforms/databases/ 比较什么时候使用这里的东西 - http://playbook.thoughtbot.com/choosing-platforms/databases/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM