SlideShare a Scribd company logo
1 of 70
Building web application




       .
                           Building web application
                                NJR 的简单介绍
       .

                                 Gaffey Eggzilla



                                 May 10, 2011




                                                  .   .   .   .   .   .
Building web application
  现状



      混乱

       Chaos / 混乱的代码/ 混乱的风格




                              .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling




                           .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁




                                .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准




                                .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling




                                .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装




                                .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效




                                .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging




                                .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)




                                        .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)
                       问题定位 (嗯, 大家懂得:)




                                         .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)
                       问题定位 (嗯, 大家懂得:)
               Log? Log!




                                         .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)
                       问题定位 (嗯, 大家懂得:)
               Log? Log!
                       BI 和 OPS 的各种要求




                                         .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)
                       问题定位 (嗯, 大家懂得:)
               Log? Log!
                       BI 和 OPS 的各种要求
                       客服 MM 的各种问题



                                         .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)
                       问题定位 (嗯, 大家懂得:)
               Log? Log!
                       BI 和 OPS 的各种要求
                       客服 MM 的各种问题
                       echo,var_dump 控


                                         .   .   .   .   .   .
Building web application
  改善



      更希望
               Calling
                       命名清晰简洁
                       接口参数标准
               Coupling
                       逻辑封装
                       调用有效
               Debuging
                       I/O(数据库、缓存...)
                       问题定位 (嗯, 大家懂得:)
               Log? Log!
                       BI 和 OPS 的各种要求
                       客服 MM 的各种问题
                       echo,var_dump 控
                       warn,info,error 们

                                           .   .   .   .   .   .
Building web application
  NJR



      NJR 来了!

               NJR(NanJi Repository) 是构建 web 应用程序的基础类库。
               它封装了操作系统和外部独立组件 (如数据库, 缓存等) 的
               API,支撑业务应用层完成数据交换和传输。




                                        .   .   .   .   .   .
Building web application
  NJR



      NJR 来了!

               NJR(NanJi Repository) 是构建 web 应用程序的基础类库。
               它封装了操作系统和外部独立组件 (如数据库, 缓存等) 的
               API,支撑业务应用层完成数据交换和传输。
       .
       NJ
       . 是南方基地的简称, 被选择做当前版本的项目代号.




                                        .   .   .   .   .   .
Building web application
  NJR Features
    autoload


      Import class
       .
       类库自动载入
       .
       defined('NJR') or
       define('NJR','/usr/share/NJR/');
       require(NJR.'NJ.php');
       //直接实例化相应的类
       $class = new NJ_Class();
       .




                                      .   .   .   .   .   .
Building web application
  NJR Features
    config


      Configure with Array
       .
       数组式的初始化配置
       .
       $class = new NJ_Class(array $conf);
       .




                                      .   .   .   .   .   .
Building web application
  NJR Features
    database


      MySQL API

               exec()




                           .   .   .   .   .   .
Building web application
  NJR Features
    database


      MySQL API

               exec()
               query()




                           .   .   .   .   .   .
Building web application
  NJR Features
    database


      MySQL API

               exec()
               query()
               setAlive()




                            .   .   .   .   .   .
Building web application
  NJR Features
    database


      MySQL API

               exec()
               query()
               setAlive()




                            .   .   .   .   .   .
Building web application
  NJR Features
    database


      MySQL API

               exec()
               query()
               setAlive()
       .
       example
       .
       $config = array('host' => '127.0.0.1','db' =>
       'mysql',
       'port' => '3306',
       'username' => 'user',
       'password' => 'pass');

       $db = new NJ_DBC($config,$debug = true, $profile
       = true);
       $db->exec();
       $db->setAlive(false);
       .                               .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API




                            .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()




                               .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()
                       set()




                               .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()
                       set()
                       del()




                               .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()
                       set()
                       del()
                       add()




                               .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()
                       set()
                       del()
                       add()
                       flush()




                                .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()
                       set()
                       del()
                       add()
                       flush()
               Array-like Retrieve




                                     .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Cache API
               Origin API
                       get()
                       set()
                       del()
                       add()
                       flush()
               Array-like Retrieve
               Serialized Store




                                     .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法
                       memcached 服务管理




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法
                       memcached 服务管理
                       key 匹配




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法
                       memcached 服务管理
                       key 匹配
               inc/des (++/–)




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法
                       memcached 服务管理
                       key 匹配
               inc/des (++/–)
               append/prepend




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法
                       memcached 服务管理
                       key 匹配
               inc/des (++/–)
               append/prepend




                                        .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Memcache
               采用 libmemcached 作为连接驱动
                       同步/异步传输
                       一致性 HASH 算法
                       memcached 服务管理
                       key 匹配
               inc/des (++/–)
               append/prepend
       .
       example
       .
       $config = array('servers' => array(0 => array('host' => '127.0.0.1',
       'port' => '11211',
       'weight'= 1),),
       'compress' => false,'serilize' => false);
       $mc = NJ_Memcache::Instance($config);
       $mc['test1'] = 'foo';
       $mc['test1']++;
       .
       $mc->append('test1','push string into end');




                                                                .     .       .   .   .   .
Building web application
  NJR Features
    cache


      APC Cache

               PHP VirtueMachine Cache(lifecycle wihin httpd process)




                                                     .   .   .    .     .   .
Building web application
  NJR Features
    cache


      APC Cache

               PHP VirtueMachine Cache(lifecycle wihin httpd process)
               Apc_Compiler_Cache(Opcode lifecycle with apc.ttl)




                                                     .   .   .     .    .   .
Building web application
  NJR Features
    cache


      APC Cache

               PHP VirtueMachine Cache(lifecycle wihin httpd process)
               Apc_Compiler_Cache(Opcode lifecycle with apc.ttl)
               Apc_User_Cache




                                                     .   .   .     .    .   .
Building web application
  NJR Features
    cache


      APC Cache

               PHP VirtueMachine Cache(lifecycle wihin httpd process)
               Apc_Compiler_Cache(Opcode lifecycle with apc.ttl)
               Apc_User_Cache




                                                     .   .   .     .    .   .
Building web application
  NJR Features
    cache


      APC Cache

               PHP VirtueMachine Cache(lifecycle wihin httpd process)
               Apc_Compiler_Cache(Opcode lifecycle with apc.ttl)
            Apc_User_Cache
       .
       hint
       .
       ./configure –enable-apc –enable-mmap –enable-apc-spinlocks
       –disable-apc-pthreadmutex




       .



                                                     .   .   .     .    .   .
Building web application
  NJR Features
    cache


      APC Cache

               PHP VirtueMachine Cache(lifecycle wihin httpd process)
               Apc_Compiler_Cache(Opcode lifecycle with apc.ttl)
            Apc_User_Cache
       .
       hint
       .
       ./configure –enable-apc –enable-mmap –enable-apc-spinlocks
       –disable-apc-pthreadmutex
       apc.stat = 0 better performance in require(),but restart httpd
       when code updated

       apc.slam_defense=0
       apc.write_lock=1
       .



                                                     .   .   .     .    .   .
Building web application
  NJR Features
    cache


      File Cache
       .
       example
       .
       $config = array('fs_path' => '/var/tmp',
       'fs_level' => 1,
       'gc_chance' => 10000, 'serilize' => false);

       $f = new NJ_Fscache($config);
       $f->add('test1','asdasdsa');
       $f->append('test1','sssssssssss');
       .




                                      .     .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)
               shared between processes




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)
               shared between processes
                       比文件系统更好




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)
               shared between processes
                       比文件系统更好
                       默认比 APC 可以存储更大的数据




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)
               shared between processes
                       比文件系统更好
                       默认比 APC 可以存储更大的数据
                       没有网络开销




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)
               shared between processes
                       比文件系统更好
                       默认比 APC 可以存储更大的数据
                       没有网络开销




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    cache


      Share Cache

               cache in local memory (’memcache’ :p)
               shared between processes
                       比文件系统更好
                       默认比 APC 可以存储更大的数据
                       没有网络开销
       .
       example
       .
       $sc = new NJ_Shcache();
       $sc['test1'] = 'foo';
       .
       $sc->close();




                                                       .   .   .   .   .   .
Building web application
  NJR Features
    network


      Remote Request

               单接口访问 send()




                              .   .   .   .   .   .
Building web application
  NJR Features
    network


      Remote Request

               单接口访问 send()
               非阻塞请求 asend()




                               .   .   .   .   .   .
Building web application
  NJR Features
    network


      Remote Request

               单接口访问 send()
               非阻塞请求 asend()




                               .   .   .   .   .   .
Building web application
  NJR Features
    network


      Remote Request

               单接口访问 send()
               非阻塞请求 asend()
       .
       example
       .
       $stack     =      array(array('url'     =>     'http://www.baidu.com','params'        =>
       array('q'=>'test','lang'=>'zh-cn'),
       'timeout'=>10),
       array('url' => 'http://www.google.com','params' => '?q=test','timeout'=>10), );

       NJ_Request::asend($stack);
       .




                                                                .     .     .     .      .        .
Building web application
  NJR Features
    log


      Log

       还没写




                           .   .   .   .   .   .
Building web application
  路线图



      更多功能

               终端程序支持 (守护进程..)




                                 .   .   .   .   .   .
Building web application
  路线图



      更多功能

               终端程序支持 (守护进程..)
               常用数据结构




                                 .   .   .   .   .   .
Building web application
  路线图



      更多功能

               终端程序支持 (守护进程..)
               常用数据结构
                       Queue




                                 .   .   .   .   .   .
Building web application
  路线图



      更多功能

               终端程序支持 (守护进程..)
               常用数据结构
                       Queue
                       Stack




                                 .   .   .   .   .   .
Building web application
  路线图



      更多功能

               终端程序支持 (守护进程..)
               常用数据结构
                       Queue
                       Stack
                       Collection




                                    .   .   .   .   .   .
Building web application
  路线图



      更多功能

               终端程序支持 (守护进程..)
               常用数据结构
                       Queue
                       Stack
                       Collection
               安全相关




                                    .   .   .   .   .   .
Building web application
  致谢



      谢谢参与

               NJR 需要配套的业务层代码




                                .   .   .   .   .   .
Building web application
  致谢



      谢谢参与

               NJR 需要配套的业务层代码
               NJR 期待各位的贡献




                                .   .   .   .   .   .
Building web application
  致谢



      谢谢参与

               NJR 需要配套的业务层代码
               NJR 期待各位的贡献
               LTEX 是一个功能强大的排版工具
               A




                                   .   .   .   .   .   .

More Related Content

Viewers also liked

Stp 07573013 d_1_1_f_d_1_0001_v (2)
Stp 07573013 d_1_1_f_d_1_0001_v (2)Stp 07573013 d_1_1_f_d_1_0001_v (2)
Stp 07573013 d_1_1_f_d_1_0001_v (2)
Erasmo Stasolla
 
Cathay pacific pp
Cathay pacific ppCathay pacific pp
Cathay pacific pp
gakapo
 
Zuraasny turluud batbayar
Zuraasny turluud batbayarZuraasny turluud batbayar
Zuraasny turluud batbayar
batbayar85
 

Viewers also liked (16)

1480 fns news 45
1480 fns news 451480 fns news 45
1480 fns news 45
 
Batbayar test
Batbayar testBatbayar test
Batbayar test
 
Importance of PDHPE
Importance of PDHPEImportance of PDHPE
Importance of PDHPE
 
Stp 07573013 d_1_1_f_d_1_0001_v (2)
Stp 07573013 d_1_1_f_d_1_0001_v (2)Stp 07573013 d_1_1_f_d_1_0001_v (2)
Stp 07573013 d_1_1_f_d_1_0001_v (2)
 
Pdhpe
PdhpePdhpe
Pdhpe
 
Cocacola
CocacolaCocacola
Cocacola
 
Webuquerque - Dynamic Duo
Webuquerque - Dynamic DuoWebuquerque - Dynamic Duo
Webuquerque - Dynamic Duo
 
Palvelumuotoilua: Ymmärränkö asiakasta?
Palvelumuotoilua: Ymmärränkö asiakasta?Palvelumuotoilua: Ymmärränkö asiakasta?
Palvelumuotoilua: Ymmärränkö asiakasta?
 
Games Are The New Normal (deck from GfK Tech Scouting conference)
Games Are The New Normal (deck from GfK Tech Scouting conference)Games Are The New Normal (deck from GfK Tech Scouting conference)
Games Are The New Normal (deck from GfK Tech Scouting conference)
 
Preseeentasjoon
PreseeentasjoonPreseeentasjoon
Preseeentasjoon
 
Reportaje fotográfico Conferencia 16 oct
Reportaje fotográfico Conferencia 16 octReportaje fotográfico Conferencia 16 oct
Reportaje fotográfico Conferencia 16 oct
 
Cathay pacific pp
Cathay pacific ppCathay pacific pp
Cathay pacific pp
 
Pygmy goats
Pygmy goatsPygmy goats
Pygmy goats
 
Zuraasny turluud batbayar
Zuraasny turluud batbayarZuraasny turluud batbayar
Zuraasny turluud batbayar
 
Les valeurs fondatrices des CPAS wallons
Les valeurs fondatrices des CPAS wallonsLes valeurs fondatrices des CPAS wallons
Les valeurs fondatrices des CPAS wallons
 
Method of data collection and analysis based in Grounded Theory
Method of data collection and analysis based in Grounded TheoryMethod of data collection and analysis based in Grounded Theory
Method of data collection and analysis based in Grounded Theory
 

Similar to PHP With NanJi

广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化
taobao.com
 
rebar erlang 2
rebar erlang 2rebar erlang 2
rebar erlang 2
致远 郑
 
企业系统商务智能设计
企业系统商务智能设计企业系统商务智能设计
企业系统商务智能设计
George Ang
 
Top100summit用友 池建强-构建企业级应用开发平台
Top100summit用友 池建强-构建企业级应用开发平台Top100summit用友 池建强-构建企业级应用开发平台
Top100summit用友 池建强-构建企业级应用开发平台
drewz lin
 
Terracotta And Continuent Based Clustering Architecture
Terracotta And Continuent Based Clustering ArchitectureTerracotta And Continuent Based Clustering Architecture
Terracotta And Continuent Based Clustering Architecture
Target Source
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介
Allen Lsy
 
An introduce to n hibernate (part 1) pub
An introduce to n hibernate (part 1) pubAn introduce to n hibernate (part 1) pub
An introduce to n hibernate (part 1) pub
jiangxu
 
OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发
leneli
 
赶集团购开发总结4
赶集团购开发总结4赶集团购开发总结4
赶集团购开发总结4
yangdj
 
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
Jackson Tian
 
广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化
leneli
 

Similar to PHP With NanJi (20)

阿里巴巴运维团队的无状态运维思路
阿里巴巴运维团队的无状态运维思路阿里巴巴运维团队的无状态运维思路
阿里巴巴运维团队的无状态运维思路
 
Sec.3 遠端安全連線解決方案-array adonis
Sec.3 遠端安全連線解決方案-array adonisSec.3 遠端安全連線解決方案-array adonis
Sec.3 遠端安全連線解決方案-array adonis
 
广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化
 
rebar erlang 2
rebar erlang 2rebar erlang 2
rebar erlang 2
 
企业系统商务智能设计
企业系统商务智能设计企业系统商务智能设计
企业系统商务智能设计
 
Cdc@ganji.com
Cdc@ganji.comCdc@ganji.com
Cdc@ganji.com
 
Top100summit用友 池建强-构建企业级应用开发平台
Top100summit用友 池建强-构建企业级应用开发平台Top100summit用友 池建强-构建企业级应用开发平台
Top100summit用友 池建强-构建企业级应用开发平台
 
Terracotta And Continuent Based Clustering Architecture
Terracotta And Continuent Based Clustering ArchitectureTerracotta And Continuent Based Clustering Architecture
Terracotta And Continuent Based Clustering Architecture
 
ASP.Net MVC2 简介
ASP.Net MVC2 简介ASP.Net MVC2 简介
ASP.Net MVC2 简介
 
An introduce to n hibernate (part 1) pub
An introduce to n hibernate (part 1) pubAn introduce to n hibernate (part 1) pub
An introduce to n hibernate (part 1) pub
 
容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中
 
Beyond rails server
Beyond rails serverBeyond rails server
Beyond rails server
 
OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发
 
赶集团购开发总结4
赶集团购开发总结4赶集团购开发总结4
赶集团购开发总结4
 
Ceph Day Shanghai - Ceph in Chinau Unicom Labs
Ceph Day Shanghai - Ceph in Chinau Unicom LabsCeph Day Shanghai - Ceph in Chinau Unicom Labs
Ceph Day Shanghai - Ceph in Chinau Unicom Labs
 
高性能的Java代码编写及常见问题排查
高性能的Java代码编写及常见问题排查高性能的Java代码编写及常见问题排查
高性能的Java代码编写及常见问题排查
 
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
 
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
从无阻塞并行脚本加载(Lab.js)到浏览器消息模型
 
广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化广告投放代码和创意代码持续优化
广告投放代码和创意代码持续优化
 
基于Symfony框架下的快速企业级应用开发
基于Symfony框架下的快速企业级应用开发基于Symfony框架下的快速企业级应用开发
基于Symfony框架下的快速企业级应用开发
 

PHP With NanJi

  • 1. Building web application . Building web application NJR 的简单介绍 . Gaffey Eggzilla May 10, 2011 . . . . . .
  • 2. Building web application 现状 混乱 Chaos / 混乱的代码/ 混乱的风格 . . . . . .
  • 3. Building web application 改善 更希望 Calling . . . . . .
  • 4. Building web application 改善 更希望 Calling 命名清晰简洁 . . . . . .
  • 5. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 . . . . . .
  • 6. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling . . . . . .
  • 7. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 . . . . . .
  • 8. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 . . . . . .
  • 9. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging . . . . . .
  • 10. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) . . . . . .
  • 11. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) 问题定位 (嗯, 大家懂得:) . . . . . .
  • 12. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) 问题定位 (嗯, 大家懂得:) Log? Log! . . . . . .
  • 13. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) 问题定位 (嗯, 大家懂得:) Log? Log! BI 和 OPS 的各种要求 . . . . . .
  • 14. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) 问题定位 (嗯, 大家懂得:) Log? Log! BI 和 OPS 的各种要求 客服 MM 的各种问题 . . . . . .
  • 15. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) 问题定位 (嗯, 大家懂得:) Log? Log! BI 和 OPS 的各种要求 客服 MM 的各种问题 echo,var_dump 控 . . . . . .
  • 16. Building web application 改善 更希望 Calling 命名清晰简洁 接口参数标准 Coupling 逻辑封装 调用有效 Debuging I/O(数据库、缓存...) 问题定位 (嗯, 大家懂得:) Log? Log! BI 和 OPS 的各种要求 客服 MM 的各种问题 echo,var_dump 控 warn,info,error 们 . . . . . .
  • 17. Building web application NJR NJR 来了! NJR(NanJi Repository) 是构建 web 应用程序的基础类库。 它封装了操作系统和外部独立组件 (如数据库, 缓存等) 的 API,支撑业务应用层完成数据交换和传输。 . . . . . .
  • 18. Building web application NJR NJR 来了! NJR(NanJi Repository) 是构建 web 应用程序的基础类库。 它封装了操作系统和外部独立组件 (如数据库, 缓存等) 的 API,支撑业务应用层完成数据交换和传输。 . NJ . 是南方基地的简称, 被选择做当前版本的项目代号. . . . . . .
  • 19. Building web application NJR Features autoload Import class . 类库自动载入 . defined('NJR') or define('NJR','/usr/share/NJR/'); require(NJR.'NJ.php'); //直接实例化相应的类 $class = new NJ_Class(); . . . . . . .
  • 20. Building web application NJR Features config Configure with Array . 数组式的初始化配置 . $class = new NJ_Class(array $conf); . . . . . . .
  • 21. Building web application NJR Features database MySQL API exec() . . . . . .
  • 22. Building web application NJR Features database MySQL API exec() query() . . . . . .
  • 23. Building web application NJR Features database MySQL API exec() query() setAlive() . . . . . .
  • 24. Building web application NJR Features database MySQL API exec() query() setAlive() . . . . . .
  • 25. Building web application NJR Features database MySQL API exec() query() setAlive() . example . $config = array('host' => '127.0.0.1','db' => 'mysql', 'port' => '3306', 'username' => 'user', 'password' => 'pass'); $db = new NJ_DBC($config,$debug = true, $profile = true); $db->exec(); $db->setAlive(false); . . . . . . .
  • 26. Building web application NJR Features cache Cache API Origin API . . . . . .
  • 27. Building web application NJR Features cache Cache API Origin API get() . . . . . .
  • 28. Building web application NJR Features cache Cache API Origin API get() set() . . . . . .
  • 29. Building web application NJR Features cache Cache API Origin API get() set() del() . . . . . .
  • 30. Building web application NJR Features cache Cache API Origin API get() set() del() add() . . . . . .
  • 31. Building web application NJR Features cache Cache API Origin API get() set() del() add() flush() . . . . . .
  • 32. Building web application NJR Features cache Cache API Origin API get() set() del() add() flush() Array-like Retrieve . . . . . .
  • 33. Building web application NJR Features cache Cache API Origin API get() set() del() add() flush() Array-like Retrieve Serialized Store . . . . . .
  • 34. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 . . . . . .
  • 35. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 . . . . . .
  • 36. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 . . . . . .
  • 37. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 memcached 服务管理 . . . . . .
  • 38. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 memcached 服务管理 key 匹配 . . . . . .
  • 39. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 memcached 服务管理 key 匹配 inc/des (++/–) . . . . . .
  • 40. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 memcached 服务管理 key 匹配 inc/des (++/–) append/prepend . . . . . .
  • 41. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 memcached 服务管理 key 匹配 inc/des (++/–) append/prepend . . . . . .
  • 42. Building web application NJR Features cache Memcache 采用 libmemcached 作为连接驱动 同步/异步传输 一致性 HASH 算法 memcached 服务管理 key 匹配 inc/des (++/–) append/prepend . example . $config = array('servers' => array(0 => array('host' => '127.0.0.1', 'port' => '11211', 'weight'= 1),), 'compress' => false,'serilize' => false); $mc = NJ_Memcache::Instance($config); $mc['test1'] = 'foo'; $mc['test1']++; . $mc->append('test1','push string into end'); . . . . . .
  • 43. Building web application NJR Features cache APC Cache PHP VirtueMachine Cache(lifecycle wihin httpd process) . . . . . .
  • 44. Building web application NJR Features cache APC Cache PHP VirtueMachine Cache(lifecycle wihin httpd process) Apc_Compiler_Cache(Opcode lifecycle with apc.ttl) . . . . . .
  • 45. Building web application NJR Features cache APC Cache PHP VirtueMachine Cache(lifecycle wihin httpd process) Apc_Compiler_Cache(Opcode lifecycle with apc.ttl) Apc_User_Cache . . . . . .
  • 46. Building web application NJR Features cache APC Cache PHP VirtueMachine Cache(lifecycle wihin httpd process) Apc_Compiler_Cache(Opcode lifecycle with apc.ttl) Apc_User_Cache . . . . . .
  • 47. Building web application NJR Features cache APC Cache PHP VirtueMachine Cache(lifecycle wihin httpd process) Apc_Compiler_Cache(Opcode lifecycle with apc.ttl) Apc_User_Cache . hint . ./configure –enable-apc –enable-mmap –enable-apc-spinlocks –disable-apc-pthreadmutex . . . . . . .
  • 48. Building web application NJR Features cache APC Cache PHP VirtueMachine Cache(lifecycle wihin httpd process) Apc_Compiler_Cache(Opcode lifecycle with apc.ttl) Apc_User_Cache . hint . ./configure –enable-apc –enable-mmap –enable-apc-spinlocks –disable-apc-pthreadmutex apc.stat = 0 better performance in require(),but restart httpd when code updated apc.slam_defense=0 apc.write_lock=1 . . . . . . .
  • 49. Building web application NJR Features cache File Cache . example . $config = array('fs_path' => '/var/tmp', 'fs_level' => 1, 'gc_chance' => 10000, 'serilize' => false); $f = new NJ_Fscache($config); $f->add('test1','asdasdsa'); $f->append('test1','sssssssssss'); . . . . . . .
  • 50. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) . . . . . .
  • 51. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) shared between processes . . . . . .
  • 52. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) shared between processes 比文件系统更好 . . . . . .
  • 53. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) shared between processes 比文件系统更好 默认比 APC 可以存储更大的数据 . . . . . .
  • 54. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) shared between processes 比文件系统更好 默认比 APC 可以存储更大的数据 没有网络开销 . . . . . .
  • 55. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) shared between processes 比文件系统更好 默认比 APC 可以存储更大的数据 没有网络开销 . . . . . .
  • 56. Building web application NJR Features cache Share Cache cache in local memory (’memcache’ :p) shared between processes 比文件系统更好 默认比 APC 可以存储更大的数据 没有网络开销 . example . $sc = new NJ_Shcache(); $sc['test1'] = 'foo'; . $sc->close(); . . . . . .
  • 57. Building web application NJR Features network Remote Request 单接口访问 send() . . . . . .
  • 58. Building web application NJR Features network Remote Request 单接口访问 send() 非阻塞请求 asend() . . . . . .
  • 59. Building web application NJR Features network Remote Request 单接口访问 send() 非阻塞请求 asend() . . . . . .
  • 60. Building web application NJR Features network Remote Request 单接口访问 send() 非阻塞请求 asend() . example . $stack = array(array('url' => 'http://www.baidu.com','params' => array('q'=>'test','lang'=>'zh-cn'), 'timeout'=>10), array('url' => 'http://www.google.com','params' => '?q=test','timeout'=>10), ); NJ_Request::asend($stack); . . . . . . .
  • 61. Building web application NJR Features log Log 还没写 . . . . . .
  • 62. Building web application 路线图 更多功能 终端程序支持 (守护进程..) . . . . . .
  • 63. Building web application 路线图 更多功能 终端程序支持 (守护进程..) 常用数据结构 . . . . . .
  • 64. Building web application 路线图 更多功能 终端程序支持 (守护进程..) 常用数据结构 Queue . . . . . .
  • 65. Building web application 路线图 更多功能 终端程序支持 (守护进程..) 常用数据结构 Queue Stack . . . . . .
  • 66. Building web application 路线图 更多功能 终端程序支持 (守护进程..) 常用数据结构 Queue Stack Collection . . . . . .
  • 67. Building web application 路线图 更多功能 终端程序支持 (守护进程..) 常用数据结构 Queue Stack Collection 安全相关 . . . . . .
  • 68. Building web application 致谢 谢谢参与 NJR 需要配套的业务层代码 . . . . . .
  • 69. Building web application 致谢 谢谢参与 NJR 需要配套的业务层代码 NJR 期待各位的贡献 . . . . . .
  • 70. Building web application 致谢 谢谢参与 NJR 需要配套的业务层代码 NJR 期待各位的贡献 LTEX 是一个功能强大的排版工具 A . . . . . .