当前位置:网站首页>Difference between redis and mongodb (useful for interview)
Difference between redis and mongodb (useful for interview)
2022-07-25 09:19:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
What is used in the project MongoDB, But why? In fact, there was not much consideration when selecting models , I just think the amount of data is relatively large , So using MongoDB.
Recently, I remembered why I used MongoDB, Just check , Summary summary summary :
I used it before redis, It was used to store some thermal data , Not much , But the operation is very frequent . Now the project uses MongoDB, At present, it is a million level data , There will be tens of millions in the future 、 Billion level .
Just Redis and MongoDB Come on , It is generally called Redis cache 、MongoDB database . This is also reasonable and justified ,
Redis Mainly store data in memory , Its “ cache ” The nature of is far greater than its “ data storage “ The nature of , The addition, deletion, modification and query of data are just as simple as variable operation ;
MongoDB But one. “ Store the data ” The system of , Adding, deleting, modifying and querying can add many conditions , It's like SQL As flexible as a database , This is very useful in the interview .
Mongodb And Redis Application index comparison
MongoDB and Redis All are NoSQL, Using structured data storage . Both of them are used in the scene , There is a certain difference , This is mainly due to In the process of memory mapping , Persistence is handled differently .MongoDB Cluster deployment is recommended , Think more about the cluster solution ,Redis More emphasis on process sequential writing , Although it supports clustering , It is also limited to the main - Slave mode .
MongoDB Syntax and existing relational databases SQL Grammatical comparison
MongoDB grammar MySql grammar
db.test.find({'name':'foobar'}) <==> select * from test where name='foobar'
db.test.find() <==> select *from test
db.test.find({'ID':10}).count() <==> select count(*) from test where ID=10
db.test.find().skip(10).limit(20) <==> select * from test limit 10,20
db.test.find({'ID':{$in:[25,35,45]}}) <==> select * from test where ID in (25,35,45)
db.test.find().sort({'ID':-1}) <==> select * from test order by IDdesc
db.test.distinct('name',{'ID':{$lt:20}}) <==> select distinct(name) from testwhere ID<20
db.test.group({key:{'name':true},cond:{'name':'foo'},reduce:function(obj,prev){prev.msum+=obj.marks;},initial:{msum:0}}) <==> select name,sum(marks) from testgroup by name
db.test.find('this.ID<20',{name:1}) <==> select name from test whereID<20
db.test.insert({'name':'foobar','age':25}) <==> insertinto test ('name','age') values('foobar',25)
db.test.remove({}) <==> delete * from test
db.test.remove({'age':20}) <==> delete test where age=20
db.test.remove({'age':{$lt:20}}) <==> delete test where age<20
db.test.remove({'age':{$lte:20}}) <==> delete test where age<=20
db.test.remove({'age':{$gt:20}}) <==> delete test where age>20
db.test.remove({'age':{$gte:20}}) <==> delete test where age>=20
db.test.remove({'age':{$ne:20}}) <==> delete test where age!=20
db.test.update({'name':'foobar'},{$set:{'age':36}})<==> update test set age=36 where name='foobar'
db.test.update({'name':'foobar'},{$inc:{'age':3}})<==> update test set age=age+3 where name='foobar'
Fuzzy query :$regex
db.test.find({"name":{$regex:"aaa"}})
Group number filtering
db.getCollection('id_mapper').aggregate([{$group:{ _id :"$contract_id",count:{$sum:1}}},{$match:{count:{$gt:1}}}])
Determine whether it is null
db.getCollection('id_mapper').find({"sinocardid":{$in:[null]}})Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/111446.html Link to the original text :https://javaforall.cn
边栏推荐
- 『怎么用』代理模式
- 整理 华为AP-3010DN_V2配置创建wifi
- Software examination system architecture designer concise tutorial | software life cycle
- canvas动态图片头像晃动js特效
- 360度拖拽全景图插件tpanorama.js
- 『每日一问』怎么实现一个正确的双重检查锁定
- Write two channel (stereo) immediately Wav file
- NFT guide for musicians
- Programmers can't SQL? Ashes Engineer: all waiting to be eliminated! This is a must skill!
- 音乐人的 NFT 指南
猜你喜欢

What are the commands used by pl/sql tools to export SQL files?

A picture to quickly understand envoyfilter in istio

Comparison between symmetric encryption and asymmetric encryption

360度拖拽全景图插件tpanorama.js

Wechat applet obtains the data of ---- onenet and controls the on-board LED of STM32

js小游戏源码魔塔闯关下载

Nacos启动报错Unable to start web server

2022-7-14 JMeter simulates the login of different users for pressure test

Opencv realizes simple face tracking

Arrange the array into the smallest number
随机推荐
【sklearn】sklearn.preprocessing.LabelEncoder
Rich text style word image processing
Do you know these methods of MySQL database optimization?
Write two channel (stereo) immediately Wav file
canvas动态图片头像晃动js特效
activemq--可持久化机制之JDBC
Composition of the interview must ask items
activemq--可持久化机制之JDBC的journal
Silicon Valley class lesson 11 - official account news and wechat authorization
Redis sentry, master-slave deployment details
API parsing of JDBC
Bi business interview with data center and business intelligence (I): preparation for Industry and business research
ActiveMQ -- message retry mechanism
How does Flink SQL persist?
activemq--持久化机制之LevelDB
Asp. Net core CMD common instructions
黑马程序员JDBC
office文件对应的Content-Type类型
2022-7-14 JMeter pressure test
[arm] Xintang nuc977 transplants wk2124 drive