<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>小亭子</title>
  
  <subtitle>荣輝</subtitle>
  <link href="/atom.xml" rel="self"/>
  
  <link href="http://shironghui.github.io/"/>
  <updated>2019-05-25T04:26:07.000Z</updated>
  <id>http://shironghui.github.io/</id>
  
  <author>
    <name>Shi ronghui</name>
    
  </author>
  
  <generator uri="http://hexo.io/">Hexo</generator>
  
  <entry>
    <title>编程思想 - OOP|AOP|SOA等术语的理解</title>
    <link href="http://shironghui.github.io/2019/05/20/%E7%BC%96%E7%A8%8B%E6%80%9D%E6%83%B3/"/>
    <id>http://shironghui.github.io/2019/05/20/编程思想/</id>
    <published>2019-05-19T19:28:00.000Z</published>
    <updated>2019-05-25T04:26:07.000Z</updated>
    
    <content type="html"><![CDATA[<h3 id="OOP"><a href="#OOP" class="headerlink" title="OOP"></a>OOP</h3><p><strong>OOP，全称：Object Oriented Programming 面向对象编程，是目前几乎所有主流编程语言都支持的编程方式，主要区别于古老的面向过程编程方式。</strong></p><h3 id="AOP"><a href="#AOP" class="headerlink" title="AOP"></a>AOP</h3><p><strong>AOP，全称：Aspect Oriented Programming 面向切面编程，最典型的应用就是Java Spring</strong></p><h3 id="SOA"><a href="#SOA" class="headerlink" title="SOA"></a>SOA</h3><p><strong>SOA，全称：Service-Oriented Architecture 面向服务的架构，我们经常所说的微服务就是应用了这种架构思想，但是SOA与微服务并不是同一概念。</strong></p><ul><li>是一种面向通用集成服务的、松耦合的架构实现方式，是web时代服务发展的产物；</li><li>使用”分层”理念，比传统的”观察者”模式更高级且更有优势，主要体现在易扩展性和可灾；</li><li>适用于大型复杂业务系统的数据共享。</li></ul><p><strong>下面是Web电商平台系统比较典型的例子（不全面，但可以帮助理解）</strong></p><p><img src="https://shironghui.github.io/images/soa.png" alt="SOA"></p><p><strong>图中的服务平台可以用不同语言实现，一般大厂多用Java实现，初创公司更偏向于php、python等实现，原因你懂的，比较通用的是RESTFUL接口模式，对于user端，只需明确接口定义，既可以使用HTTP/HTTPS进行通讯，理论上是无限量的。</strong></p><p><strong>SOA对于客户端来说极大的简化了开发周期。对于一个特殊需求的出现不会措手不及，更不会大动干戈重构底层，开发者不需要知道具体底层原理即可快速开发实现功能。</strong></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h3 id=&quot;OOP&quot;&gt;&lt;a href=&quot;#OOP&quot; class=&quot;headerlink&quot; title=&quot;OOP&quot;&gt;&lt;/a&gt;OOP&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;OOP，全称：Object Oriented Programming 面向对象编程，是目前几乎所有主流编程语言都支持
      
    
    </summary>
    
      <category term="编程思想" scheme="http://shironghui.github.io/categories/%E7%BC%96%E7%A8%8B%E6%80%9D%E6%83%B3/"/>
    
    
      <category term="编程思想" scheme="http://shironghui.github.io/tags/%E7%BC%96%E7%A8%8B%E6%80%9D%E6%83%B3/"/>
    
  </entry>
  
  <entry>
    <title>Python 基础知识</title>
    <link href="http://shironghui.github.io/2019/05/20/Python-%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/"/>
    <id>http://shironghui.github.io/2019/05/20/Python-基础知识/</id>
    <published>2019-05-19T18:18:30.000Z</published>
    <updated>2019-05-25T04:25:32.000Z</updated>
    
    <content type="html"><![CDATA[<p><img src="https://shironghui.github.io/images/py.png" alt="PY知识图谱" title="PY知识图谱&quot;"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;p&gt;&lt;img src=&quot;https://shironghui.github.io/images/py.png&quot; alt=&quot;PY知识图谱&quot; title=&quot;PY知识图谱&amp;quot;&quot;&gt;&lt;/p&gt;

      
    
    </summary>
    
      <category term="Python" scheme="http://shironghui.github.io/categories/Python/"/>
    
    
      <category term="Python" scheme="http://shironghui.github.io/tags/Python/"/>
    
  </entry>
  
  <entry>
    <title>Java 类与对象</title>
    <link href="http://shironghui.github.io/2019/05/20/java-class/"/>
    <id>http://shironghui.github.io/2019/05/20/java-class/</id>
    <published>2019-05-19T17:48:05.000Z</published>
    <updated>2019-05-25T04:25:32.000Z</updated>
    
    <content type="html"><![CDATA[<h3 id="简单的讲，JAVA中的面向对象主要应用于类（class）"><a href="#简单的讲，JAVA中的面向对象主要应用于类（class）" class="headerlink" title="简单的讲，JAVA中的面向对象主要应用于类（class）"></a>简单的讲，JAVA中的面向对象主要应用于类（class）</h3><p><strong>在java中，类主要包括以下若干概念：常量、变量、构造函数、普通方法、析构函数，先简单介绍下基础，然后看一段Demo代码，看看你对java中的 类 理解如何</strong></p><ul><li>java关键字final用在变量的前面表示变量的值不可以改变，称为常量；</li><li>静态变量在内存中是共享的，与实例变量不同；</li><li>静态代码块在类加载时运行；</li><li>任何 Java 类都可以覆盖Object类提供的 protected 类型的 finalize() 方法作为析构方法，析构方法与构造方法相反，当对象销毁时自动执行。</li></ul><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">package com.company.ronghui.shi;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Counter</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> int number = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    Counter() &#123;</span><br><span class="line">        init();</span><br><span class="line">        number++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> &#123;</span><br><span class="line">        number++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> void init() &#123;</span><br><span class="line">        number++;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> int getCount() &#123;</span><br><span class="line">        <span class="keyword">return</span> number;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">protected</span> void finalize() &#123;</span><br><span class="line">        number--;</span><br><span class="line">        System.out.println(<span class="string">"Final number: "</span> + number);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><figure class="highlight php"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">package com.company.ronghui.shi;</span><br><span class="line"></span><br><span class="line">import java.lang.String;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Main</span></span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> void main(String args[]) &#123;</span><br><span class="line">        run();</span><br><span class="line">        Runtime.getRuntime().gc();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> void run() &#123;</span><br><span class="line">        <span class="keyword">for</span> (int i = <span class="number">1</span>; i &lt;= <span class="number">3</span>; i++) &#123;</span><br><span class="line">            System.out.println((<span class="keyword">new</span> Counter()).getCount());</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure><h4 id="正确答案"><a href="#正确答案" class="headerlink" title="正确答案"></a>正确答案</h4><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">3</span><br><span class="line">5</span><br><span class="line">7</span><br><span class="line">Final number: 6</span><br><span class="line">Final number: 5</span><br><span class="line">Final number: 4</span><br></pre></td></tr></table></figure>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h3 id=&quot;简单的讲，JAVA中的面向对象主要应用于类（class）&quot;&gt;&lt;a href=&quot;#简单的讲，JAVA中的面向对象主要应用于类（class）&quot; class=&quot;headerlink&quot; title=&quot;简单的讲，JAVA中的面向对象主要应用于类（class）&quot;&gt;&lt;/a&gt;简单
      
    
    </summary>
    
      <category term="Java" scheme="http://shironghui.github.io/categories/Java/"/>
    
    
      <category term="Java" scheme="http://shironghui.github.io/tags/Java/"/>
    
  </entry>
  
  <entry>
    <title>PHP 基础知识</title>
    <link href="http://shironghui.github.io/2019/05/20/PHP-%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/"/>
    <id>http://shironghui.github.io/2019/05/20/PHP-基础知识/</id>
    <published>2019-05-19T17:30:00.000Z</published>
    <updated>2019-05-25T04:25:32.000Z</updated>
    
    <content type="html"><![CDATA[<h3 id="主流框架"><a href="#主流框架" class="headerlink" title="主流框架"></a>主流框架</h3><ul><li>入门学习框架：ThinkPHP</li><li>主流高端框架：Laravel, Yii, CI, Zend Framework</li><li>其他特色框架：Symfony, Phalcon, CakePHP等</li></ul>]]></content>
    
    <summary type="html">
    
      
      
        &lt;h3 id=&quot;主流框架&quot;&gt;&lt;a href=&quot;#主流框架&quot; class=&quot;headerlink&quot; title=&quot;主流框架&quot;&gt;&lt;/a&gt;主流框架&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;入门学习框架：ThinkPHP&lt;/li&gt;
&lt;li&gt;主流高端框架：Laravel, Yii, CI, Zend F
      
    
    </summary>
    
      <category term="PHP" scheme="http://shironghui.github.io/categories/PHP/"/>
    
    
      <category term="PHP" scheme="http://shironghui.github.io/tags/PHP/"/>
    
  </entry>
  
  <entry>
    <title>Redis 高可用设计方案</title>
    <link href="http://shironghui.github.io/2019/05/20/Redis%E9%AB%98%E5%8F%AF%E7%94%A8%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1%E6%80%9D%E8%B7%AF/"/>
    <id>http://shironghui.github.io/2019/05/20/Redis高可用系统架构设计思路/</id>
    <published>2019-05-19T17:08:05.000Z</published>
    <updated>2019-05-25T04:25:45.000Z</updated>
    
    <content type="html"><![CDATA[<blockquote><p><strong>先介绍几个概念知识，为整体架构作铺垫</strong></p></blockquote><ul><li><p>Codis</p><p>分布式服务框架</p></li><li><p>Twemproxy</p><p>代理服务器</p></li></ul><p>首先，最简单的Redis应用称为单点模式：即只有一台Redis服务器与客户端直连。</p><p><img src="https://shironghui.github.io/images/redis-one.jpg" alt="Redis-Cluster"></p><p>当QPS不断增加，单点Redis不足以支撑业务的时候，就是最应该优化的时候，毕竟业务驱动技术改进，脱离业务的技术改造都是耍流氓，这话出自业内某位大神，但是真不是鲁迅先生，哈哈。<br>此时，我们想到的是加一台服务器作为从库，实现读写分离。<br>但是如果业务场景出现频繁读数据或频繁写数据，那么此时和单点模式基本相同，此时我们有两种方式可以优化系统：</p><ol><li>我们可以充分利用两台服务器实现双写双读模式，此时需要开发进行大量的编码工作，以保障双写双读的可靠性。</li><li>如果想对服务器内存有更大的需求，可以考虑分片，具体实现何种分片还要具体问题具体分析。</li></ol><p><img src="https://shironghui.github.io/images/redis-master.jpg" alt="Redis-Cluster"></p><p>对于上面的方案，我们基本完成了一次系统优化迭代。优势显而易见：代码独立，不依赖于第三方中间件等，但是更明显的应该是缺点：</p><ul><li>系统整体升级困难</li><li>扩缩容非常复杂</li><li>突发性故障屏蔽转移需要很大的人力成本</li></ul><p>坦白的说，只要你稍微思考的远一些，站的角度高一些，你会发现上面的系统是最初级的，有很大的优化空间，而且现在的技术发展可以很好的解决以上问题，那就是代理模式。</p><h3 id="Redis代理方案"><a href="#Redis代理方案" class="headerlink" title="Redis代理方案"></a>Redis代理方案</h3><p>说到代理中间件，就用到了一开始简单的介绍的Codis和Twemproxy。 但是代理也不是完美无缺，比如多多少少会影响一些性能，需要购买多余的机器等问题。</p><p><img src="https://shironghui.github.io/images/redis-proxy.jpg" alt="Redis-Cluster"></p><h3 id="Redis-Cluster"><a href="#Redis-Cluster" class="headerlink" title="Redis Cluster"></a>Redis Cluster</h3><p>这是Redis.io官方推荐的高可用Redis集群解决方案，采用去中心化思想，这点估计是借鉴了区块链技术中的无中心化思想吧（在下YY的，忽略），方便管理增删服务节点，很重要的一点是文档丰富、生态良好~</p><p><img src="https://shironghui.github.io/images/redis-cluster.jpg" alt="Redis-Cluster"></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;先介绍几个概念知识，为整体架构作铺垫&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Codis&lt;/p&gt;
&lt;p&gt;分布式服务框架&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Twemproxy&lt;/p&gt;
&lt;p&gt;代理服
      
    
    </summary>
    
      <category term="Redis" scheme="http://shironghui.github.io/categories/Redis/"/>
    
    
      <category term="Redis" scheme="http://shironghui.github.io/tags/Redis/"/>
    
  </entry>
  
  <entry>
    <title>Redis 命令手册</title>
    <link href="http://shironghui.github.io/2019/05/20/Redis%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E6%89%8B%E5%86%8C/"/>
    <id>http://shironghui.github.io/2019/05/20/Redis常用命令手册/</id>
    <published>2019-05-19T16:48:05.000Z</published>
    <updated>2019-05-25T04:35:22.000Z</updated>
    
    <content type="html"><![CDATA[<ol><li><p>GET key<br>查询key对应的值value；</p></li><li><p>SET key value [有效期（可选参数）]<br>设置key的值value，如果key已经存在，则覆盖原有的值；</p></li><li><p>INCR key<br>将key对应的数值加1，如果key不存在，则默认在0的基础上加1，返回1；</p></li><li><p>DECR key<br>将key对应的数值减1，如果key不存在，则默认在0的基础上减1，返回-1；</p></li><li><p>EXISTS key [key2 key3 …]<br>用途：判断key是否存在，目前已支持查询多个key是否存在；<br>返回：单个key不存在时返回0，存在时返回存在的key的数量，如1，2，3；</p></li><li><p>EXPIRE key xxx（秒数）<br>将key的超时时间设置为xxx,单位秒；</p></li></ol>]]></content>
    
    <summary type="html">
    
      
      
        &lt;ol&gt;
&lt;li&gt;&lt;p&gt;GET key&lt;br&gt;查询key对应的值value；&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SET key value [有效期（可选参数）]&lt;br&gt;设置key的值value，如果key已经存在，则覆盖原有的值；&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;INCR k
      
    
    </summary>
    
      <category term="Redis" scheme="http://shironghui.github.io/categories/Redis/"/>
    
    
      <category term="Redis" scheme="http://shironghui.github.io/tags/Redis/"/>
    
  </entry>
  
</feed>
