• review


    一、123
    第二部分:面向对象
            1. 谈谈你对面向对象的认识。
            
            2. 约束 
                Java: 
                    - 接口,约子类中必须包含某个方法(约束)。
                        Interface IMessage:
                            def func1(self):
                                pass 
                            def func2(self):
                                pass 
                                
                        class Msg(IMessage):
                            def func1(self):
                                print('func1') 
                            def func2(self):
                                print('func1') 
                    
                    - 抽象方法/抽象类,约子类中必须包含某个方法。(约束+继承)
                        class abstract IMessage:
                            def abstract func1(self):
                                pass 
                            def abstract func2(self):
                                pass 
                            
                            def func3(self):
                                print('asdfasdf') 
                                
                        class Msg(IMessage):
                            def func1(self):
                                print('func1') 
                            def func2(self):
                                print('func1') 
                
                Python:
                    - 接口(无)
                    - 抽象方法/抽象类(有,ABC)
                    
                    - 类继承+异常
                        
                        class IMessage(object):
    
                            def func1(self):
                                raise NotImplementedError('子类没有实现func1方法')
    
    
                        class Msg(IMessage):
                            def func1(self):
                                print('123')
    
    
                        obj = Msg()
                        obj.func1()
                        
                有什么用?用于告知其他人以后继承时,需要实现那个方法,如:
                    
                    class BaseAuthentication(object):
                        """
                        All authentication classes should extend BaseAuthentication.
                        """
    
                        def authenticate(self, request):
                            """
                            Authenticate the request and return a two-tuple of (user, token).
                            """
                            raise NotImplementedError(".authenticate() must be overridden.")
    
                        def authenticate_header(self, request):
                            """
                            Return a string to be used as the value of the `WWW-Authenticate`
                            header in a `401 Unauthenticated` response, or `None` if the
                            authentication scheme should return `403 Permission Denied` responses.
                            """
                            pass
    
                
                以后自己开发时,如何使用?
                    需求:
                        class BaseMessage(object):
    
                            def send(self):
                                raise NotImplementedError('必须实现send方法')
    
    
                        class Msg(BaseMessage):
                            def send(self):
                                print('发送短信')
    
    
                        class Wechat(BaseMessage):
                            def send(self):
                                print('发送微信')
    
    
                        class Email(BaseMessage):
                            def send(self):
                                print('发送邮件')
    
    
    
                        class DingDing(BaseMessage):
                            def send(self):
                                print('发送钉钉提醒')
                    
                
            3. __dict__
            
            4. metaclass 
        

    2、124

    第二部分:面向对象
            1. 面向对象的认识。
            
            2. 特殊方法
                __enter__
                __exit__
                
            3. 约束 
                java:
                    - 接口
                    - 抽象方法抽象类
                python:
                    - 接口(无)
                    - 抽象方法抽象类
                        import abc
                        class Base(metaclass=abc.ABCMeta):
    
                            @abc.abstractmethod
                            def send(self):pass
    
                            def func(self):
                                print(123)
    
                        class Foo(Base):
    
                            def send(self):
                                print('发送信息')
    
    
                        obj = Foo()
                        obj.send()
                        obj.func()
                    - 继承+剖出异常 (*class Base(object):
    
                            def send(self):
                                raise NotImplementedError('子类中必须实现send方法')
    
    
                        class Foo(Base):
    
                            def send1(self):
                                print('234')
    
                        obj = Foo()
                        obj.send()
                    
            
            4. metaclass作用:指定类由那个type创建?(type泛指继承type的所有类)
                    
                
        第三部分:数据库
            1. 引擎 
                - innodb
                    - 表/- 事务
                    -- mysiam
                    -- 无事务
                    -2. 数据库如何加锁?
                终端1:
                    begin;
                    select * from tb for update;
                    commit;
                
                终端2:
                    begin;
                    select * from tb for update;
                    commit;
            
            3. 什么时候需要加锁?
                - 计数
                - 应用场景:
                    - 商品数量
                    
            4. 了解:
                - 视图
                - 触发器
                - 函数 
                - 存储过程
                
            5. 索引
                
            6. 无法命中?
                
            7. 慢日志?
                - 查询时间久
                - 未命中索引
                
                修改配置:
                    slow_query_log = ON                            是否开启慢日志记录
                    long_query_time = 2                              时间限制,超过此时间,则记录
                    slow_query_log_file = /usr/slow.log        日志文件
                    log_queries_not_using_indexes = ON     为使用索引的搜索是否记录
                
            8. 执行计划
                explain select * from tb; 
                 id
                    查询顺序标识
                        如:mysql> explain select * from (select nid,name from tb1 where nid < 10) as B;
                        +----+-------------+------------+-------+---------------+---------+---------+------+------+-------------+
                        | id | select_type | table      | type  | possible_keys | key     | key_len | ref  | rows | Extra       |
                        +----+-------------+------------+-------+---------------+---------+---------+------+------+-------------+
                        |  1 | PRIMARY     | <derived2> | ALL   | NULL          | NULL    | NULL    | NULL |    9 | NULL        |
                        |  2 | DERIVED     | tb1        | range | PRIMARY       | PRIMARY | 8       | NULL |    9 | Using where |
                        +----+-------------+------------+-------+---------------+---------+---------+------+------+-------------+
                    特别的:如果使用union连接气值可能为null
    
    
                select_type
                    查询类型
                        SIMPLE          简单查询
                        PRIMARY         最外层查询
                        SUBQUERY        映射为子查询
                        DERIVED         子查询
                        UNION           联合
                        UNION RESULT    使用联合的结果
                        ...
                table
                    正在访问的表名
    
    
                type
                    查询时的访问方式,性能:all < index < range < index_merge < ref_or_null < ref < eq_ref < system/const
                        ALL             全表扫描,对于数据表从头到尾找一遍
                                        select * from tb1;
                                        特别的:如果有limit限制,则找到之后就不在继续向下扫描
                                               select * from tb1 where email = 'seven@live.com'
                                               select * from tb1 where email = 'seven@live.com' limit 1;
                                               虽然上述两个语句都会进行全表扫描,第二句使用了limit,则找到一个后就不再继续扫描。
    
                        INDEX           全索引扫描,对索引从头到尾找一遍
                                        select nid from tb1;
    
                        RANGE          对索引列进行范围查找
                                        select *  from tb1 where name < 'alex';
                                        PS:
                                            between and
                                            in
                                            >   >=  <   <=  操作
                                            注意:!= 和 > 符号
    
    
                        INDEX_MERGE     合并索引,使用多个单列索引搜索
                                        select *  from tb1 where name = 'alex' or nid in (11,22,33);
    
                        REF             根据索引查找一个或多个值
                                        select *  from tb1 where name = 'seven';
    
                        EQ_REF          连接时使用primary key 或 unique类型
                                        select tb2.nid,tb1.name from tb2 left join tb1 on tb2.nid = tb1.nid;
    
    
    
                        CONST           常量
                                        表最多有一个匹配行,因为仅有一行,在这行的列值可被优化器剩余部分认为是常数,const表很快,因为它们只读取一次。
                                        select nid from tb1 where nid = 2 ;
    
                        SYSTEM          系统
                                        表仅有一行(=系统表)。这是const联接类型的一个特例。
                                        select * from (select nid from tb1 where nid = 1) as A;
                possible_keys
                    可能使用的索引
    
                key
                    真实使用的
    
                key_len
                    MySQL中使用索引字节长度
    
                rows
                    mysql估计为了找到所需的行而要读取的行数 ------ 只是预估值
    
                extra
                    该列包含MySQL解决查询的详细信息
                    “Using index”
                        此值表示mysql将使用覆盖索引,以避免访问表。不要把覆盖索引和index访问类型弄混了。
                    “Using where”
                        这意味着mysql服务器将在存储引擎检索行后再进行过滤,许多where条件里涉及索引中的列,当(并且如果)它读取索引时,就能被存储引擎检验,因此不是所有带where子句的查询都会显示“Using where”。有时“Using where”的出现就是一个暗示:查询可受益于不同的索引。
                    “Using temporary”
                        这意味着mysql在对查询结果排序时会使用一个临时表。
                    “Using filesort”
                        这意味着mysql会对结果使用一个外部索引排序,而不是按索引次序从表里读取行。mysql有两种文件排序算法,这两种排序方式都可以在内存或者磁盘上完成,explain不会告诉你mysql将使用哪一种文件排序,也不会告诉你排序会在内存里还是磁盘上完成。
                    “Range checked for each record(index map: N)”
                        这个意味着没有好用的索引,新的索引将在联接的每一行上重新估算,N是显示在possible_keys列中索引的位图,并且是冗余的。
                
            9. 优化方案:
                - 不使用select * 
                - 短索引 
                - 使用链表代替子查询
                - 固定长度在前面
                - 分库分表
                - 组合索引 > 索引合并
                - 内存代替链表
                    - choices
                - limit 
                - 读写分离(主从)
                - 分页 
                - 缓存
                
                
                select id,1 from tb;
    View Code

    3、125

    第二部分:并发和网络编程
       1. OSI 7层模型
       
       2. 三次握手、四次挥手?
       
       3. TCP和UDP区别?
       
       4. 路由器和交换机的区别?
       
       5. ARP协议?
       
       6. DNS解析?
       
       7. Http和Https?
       
       8. 进程、线程、协程区别?
       
       9. GIL锁
       
       10. 进程如何进程共享?
    View Code

     4、126

        1. OSI 7/5 层模型
            
            2. 三次握手、四次挥手?
            
            3. TCP和UDP区别?
            
            4. 路由器和交换机的区别?
            
            5. ARP协议?
                
            6. DNS解析?
            
            7. Http和Https?
            
            8. 进程、线程、协程区别?
            
            9. GIL锁
                全局解释器锁,保证同一时刻一个进程只有一个线程被CPU调度。
                数据安全:自己加锁。
            10. 进程如何进程共享?
                - queque
                - pipe 
                - manager
    View Code










  • 相关阅读:
    JavaScript对象的几种创建方式?
    TCP 三次握手,四次挥手
    常用的状态码
    前后端分离的接口规范
    京东架构师:日均 5 亿查询量的ElasticSearch架构如何设计?
    [转] 谈谈Spring中都用到了那些设计模式?
    [转]Post和Get的区别
    [转]17个常用的JVM参数
    从入门到熟悉HTTPS的9个问题
    布式事务和解决方案理论
  • 原文地址:https://www.cnblogs.com/di2wu/p/10292368.html
Copyright © 2020-2023  润新知