Review of NoSQL and Redis Five Jobs

1. Assignment 1

Requirements:
Install CentOS Linux system on VM, install C++ compiler through yum on Linux, and compile and install Redis.

Observe the Redis directory structure, use redis-server to start the server, use front-end mode and back-end mode to start respectively
Take screenshots of the running commands, server status, logs and other information, organize them into word, and submit the word file.

1. The command to run:

[souranker@localhost ~]$ su root
[root@localhost souranker]# cd root
[root@localhost souranker]# tar -zxvf redis-3.0.7.tar.gz
[root@localhost souranker]# cd redis-3.0.7
[root@localhost redis-3.0.7]# yum install gcc-c++ -y
[root@localhost redis-3.0.7]# make
[root@localhost redis-3.0.7]# make install
[root@localhost redis-3.0.7]# cd /usr/local/bin
[root@localhost redis-3.0.7]# redis-server
[root@localhost redis-3.0.7]# cp redis.conf /usr/local/bin
[root@localhost redis-3.0.7]# cd /usr/local/bin
[root@localhost redis-3.0.7]# vim redis.conf
[root@localhost redis-3.0.7]# redis-server ./redis.conf
[root@localhost redis-3.0.7]# ps -ef | grep redis

2. Information screenshot:

insert image description here
insert image description here

2. Assignment 2

Require:

  1. Create multiple redis.conf files, modify the port number, start multiple redis servers, and use ps to observe the server process.
  2. Implement the following operations in redis:
    1) Delete all data in the existing warehouse
    2) Switch to the database numbered 2
    3) Add new key-value pairs to store student number, name, age, and gender respectively
    4) Switch to the database numbered 3 get the database, use the hash method to store the student object, save the student number, name, age, gender information
    5) switch to the number 4 database, use the list method to store the student number, name, age, gender information
    6) respectively in the 234 database Add email data and delete gender information
  3. Take screenshots of the running commands, server status, logs and other information, organize them into word, and submit the word file.

Information screenshot:

insert image description here

insert image description here
insert image description here

insert image description here
insert image description here

insert image description here

insert image description here
insert image description here
insert image description here

3. Assignment 3

Implement the following operations in java:
1.String type
1) Delete all data in the existing warehouse
2) Switch to the database numbered 0
3) Add key-value pairs to store student number, name, age, gender respectively

insert image description here
insert image description here

insert image description here
2. Hash type
1) Switch to the database numbered 1, use the hash method to store the student object, save the student number, name, age, gender information 2) the
console prints the field name and field value separately
3) delete the gender information

insert image description here

insert image description here

insert image description here

insert image description here

insert image description here
insert image description here

3. List type
1) Switch to the database numbered 2, use the list method to store student number, name, age, gender information, and print it on the console 2) Add
mailbox information before gender information
3) Delete gender information

insert image description here

insert image description here
insert image description here
insert image description here

insert image description here

4. Assignment 4

Implement the following functions through Java code

  1. Use the set type to implement the following operations in redis:
    1) Add the grades of 3 classes, each class uses a set description, and the key is the class number
    2) Check all the unique grades in the 3 classes
    3) Compare the first and the first For the results of the second class, check the difference between the second class and the first class.
    4) Take screenshots of the running commands, server status, logs and other information, organize them into word, and submit the word file.

insert image description here
insert image description here

insert image description here

insert image description here

2. Use the zset type to achieve the following operations:
1) Store user names and points
2) Arrange the names of all users according to the points from high to low
3) View the ranking of users whose name is tom
4) View all users with points within 1000-5000
5) Take screenshots of the running commands, server status, logs and other information, organize them into word, and submit the word file.
insert image description here
insert image description here

insert image description here

5. Assignment 5

1. Use mybatis to connect to the mysql database and debug successfully
2. Configure and implement redis instead of mybatis secondary cache
3. Implement redis to automatically cache mysql data and test

package com.igeek.bean;

import java.util.Date;

public class Student {
    
    
    private String ID;
    private String name;
    private Date birthday;
    private Double score;
    private String major;
    private String telphone;

    @Override
    public String toString() {
    
    
        return "Student{" +
                "ID='" + ID + '\'' +
                ", name='" + name + '\'' +
                ", birthday=" + birthday +
                ", score=" + score +
                ", major='" + major + '\'' +
                ", telphone='" + telphone + '\'' +
                '}';
    }

    public String getID() {
    
    
        return ID;
    }

    public void setID(String ID) {
    
    
        this.ID = ID;
    }

    public String getName() {
    
    
        return name;
    }

    public void setName(String name) {
    
    
        this.name = name;
    }

    public Date getBirthday() {
    
    
        return birthday;
    }

    public void setBirthday(Date birthday) {
    
    
        this.birthday = birthday;
    }

    public double getScore() {
    
    
        return score;
    }

    public void setScore(double score) {
    
    
        this.score = score;
    }

    public String getMajor() {
    
    
        return major;
    }

    public void setMajor(String major) {
    
    
        this.major = major;
    }

    public String getTelphone() {
    
    
        return telphone;
    }

    public void setTelphone(String telphone) {
    
    
        this.telphone = telphone;
    }
}

package com.igeek.mapper;

        import com.igeek.bean.Student;

public interface StudentMapper {
    
    

    Student selectById(String ID);

}







package com.igeek.utils;

        import com.igeek.cache.RedisCache;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.data.redis.core.RedisTemplate;
        import org.springframework.stereotype.Component;

@Component
public class RedisCacheTranster {
    
    
    @Autowired
    public  void setRedisTemplate(RedisTemplate redisTemplate){
    
    
        RedisCache.setRedisTemplate(redisTemplate);
    }
}

    <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.igeek.mapper.StudentMapper">

<!--    <cache type="cache.RedisCache"/>-->

<!--    <cache type="com.igeek.cache.RedisCache"/>-->
<!--auto generated Code-->
<select id="selectById" useCache="true" parameterType="String" resultType="com.igeek.bean.Student">
        SELECT *
        FROM student
        where id=#{id}
</select>

</mapper>

        import com.igeek.bean.Student;
        import com.igeek.mapper.StudentMapper;
        import org.junit.Test;
        import org.junit.runner.RunWith;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.test.context.ContextConfiguration;
        import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class TestMapper {
    
    
    @Autowired
    StudentMapper studentMapper;
    @Test
    public void test1(){
    
    
        System.out.println("---------第一次查询---------");
        Student student=studentMapper.selectById("1001");
        System.out.println(student);
        System.out.println("---------第二次查询---------");
        Student student1=studentMapper.selectById("1001");
        System.out.println(student);
    }


}

insert image description here

Guess you like

Origin blog.csdn.net/m0_48170265/article/details/130024365