Mongodb,redis Simple Learning

Source: Internet
Author: User
Tags mongoclient

2.MONGODB installation Configuration Simple LearningConfiguring the database path allows the MONGO command to perform an interactive operation: Start the server first, and perform an interactive operation with a CMD1) Increase and deletion checkInsert Method: Dp.person.insert ({"Name": "Jack", "Age": ())Find Method:db.person.find (); Db.person.find ({"Name": Joe})                                      1. $type matched filter: db.person. Find " name" : { $type : 2                                      2. limit, Skip:db person. (). Limit1 (1) 3.sort ():1 Ascending,-1 descending db. Person. Find(). Sort({"_id":-1}) Update method: Db.person.update ({"Name": "Joe"},{"name": "Joe", "Age": ())Remove Method: Db.person.remove ({"Name": "Joe"})2) Create database:use database_name; Delete database:db. Dropdatabase(); Show DBS: View So database 3) View the collection in the database: show tables, delete this collection: Db. Collection name. Drop ()                 4) index creation: db. Col. Ensureindex ({ "title" :1                 5) aggregation operation: dbmycol. ([{ $group : { _id : "$by _user" , num_tutorial : { $sum : 1}}]) = Select By_user, COUNT (*) from MyCol GROUP by By_user     6) How to use in Java: http://www.runoob.com/mongodb/mongodb-java.html1. Lead jar Package

2. Connect to the database//Connect MongoDB service, connect database                                  mongoclient Mongoclient = new mongoclient ( "localhost" , 27017 mongodatabase mongodatabase = mongoclient. Getdatabase("MyCol"); 7) Visual Session management tool rockmongo:http://download.csdn.net/download/abc_key/7482165 download and easy to use3.redis installation Configuration Simple LearningRedis runs in memory but can be persisted to the hard disk so that it can do a lot of internal complexityOpen cmd Window server side redis-server.exe redis.windows.conf; open cmd window opening client: redis-cli.exe-h 127.0.0.1-p 63791.redis configuration :config get *, can be configured to touch a configuration item 2. Basic operation: Store data in key-value pairs1) string:set name "Xiaoping"; get name; a key can store up to 512MB2) Hash: Each hash can store 2 of the 32-second-key-value pairsHset (set hash one field) Hget (GET)Hmset (Set hash multiple fields) Hmget (GET)3) List: can store up to 232-1 elements: save one to one key at a timecontinuous insertion of data: Lpush user3 xiaoping;lpush user3 laoli;lpush user3 Xiaowangget the key value part value collection: Lrange user3 14) Set: can store up to 232-1: save one to one key at a timecontinuous insertion of data: Sadd user4 xiaoping;sadd user4 Laoli;get the key value part value collection: Smembers user45) Zset: ordered set;Zset members are unique, but fractions (score) can be duplicated: Zadd key score member continuous insertion of data: Zadd user5 0 xiaoping;zadd user5 0 laoli;zadd user5 0 XiaopingSort by fractions gets the value of the specified range key ordered collection Zrangebyscore User5 03. Many operations for keys: http://www.runoob.com/redis/redis-keys.html Using redis:http://www.runoob.com/redis/redis-java.html in 4.java 5. Visualization tool: Redis Management platform http://www.liqucn.com/rj/817600.shtml 

Mongodb,redis Simple Learning

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.