From 7d7ba8bc6c7d7ef99a279b68147a69133f4aedbf Mon Sep 17 00:00:00 2001 From: Sky Date: Thu, 21 Apr 2016 15:43:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26c583f..5cfc153 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # iBlog2 -基于 Node.js 的个人开源博客系统,采用响应式布局,支持电脑、手机等直接访问,简单实用,美观大方。 -(基于 ASP.NET 的 iBlog 点击[这里](https://github.com/eshengsky/iBlog/)) +基于 Node.js 的个人开源博客系统,采用响应式布局,支持移动设备直接访问,功能全面,美观大方。 +(基于 ASP.NET 的版本请点击[这里](https://github.com/eshengsky/iBlog/)) ## 在线实例 个人博客 [http://www.skysun.name/](http://www.skysun.name/) @@ -67,9 +67,19 @@ $ bower install ``` 在 "后台管理-系统设置" 页面中,支持以可视化方式配置其余参数。 #### 启动站点 +* 方式1:普通模式启动 ```Shell $ node --harmony-proxies ./bin/www ``` +* 方式2:快速启动 +```Shell +$ npm start +``` +* 方式3:守护进程启动 +_守护进程能够发挥多核CPU性能,并在出现异常退出后延迟30秒自动重启工作进程。_ +```Shell +$ node --harmony-proxies daemon.js +``` 打开浏览器,访问 [http://localhost:3000/](http://localhost:3000) #### Enjoy it! :smile: @@ -77,7 +87,7 @@ $ node --harmony-proxies ./bin/www 文章分类、文章列表、文章详细等都作了缓存处理,若想使修改立即可见,需要在"后台管理-缓存管理"页面手动清除缓存。 ## 线上部署 -推荐使用[pm2](https://github.com/Unitech/pm2)进行线上Node.js的进程管理和持久运行。 +推荐使用 [pm2](https://github.com/Unitech/pm2) 进行线上Node.js的进程管理和持久运行。 #### 安装 ```Shell $ npm install -g pm2 From ffd0ba9cc3262a2841f549139ea836440634daea Mon Sep 17 00:00:00 2001 From: Sky Date: Thu, 21 Apr 2016 20:47:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5cfc153..4c6e231 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ ## 在线实例 个人博客 [http://www.skysun.name/](http://www.skysun.name/) +## [Wiki](https://github.com/eshengsky/iBlog2/wiki) +该 Wiki 汇总了 iBlog2 中涉及 Node.js 及部分前端技术的基本功能与知识点,适合新手学习、备查。 + ## 功能模块 #### 博客 * 文章列表页 From 5a5d9122bf0bbd6bf09d3be6f6f99b8b452ce255 Mon Sep 17 00:00:00 2001 From: Sky Date: Thu, 21 Apr 2016 23:56:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E7=82=B9?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E9=85=8D=E5=90=88Wiki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/category.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proxy/category.js b/proxy/category.js index 3cb90a6..76417c8 100644 --- a/proxy/category.js +++ b/proxy/category.js @@ -34,16 +34,22 @@ exports.getAll = function (isAll, cached, callback) { isAll = true; cached = true; } + //缓存的key名称 var cache_key = isAll ? 'categories_all' : 'categories'; if (cached) { + //尝试读取缓存 redisClient.getItem(cache_key, function (err, categories) { + //读取缓存出错 if (err) { return callback(err); } + //缓存中有数据 if (categories) { return callback(null, categories); } + //缓存中没有数据,则从数据库中读取 categoryModel.find(function (err, categories) { + //读取数据库出错 if (err) { return callback(err); } @@ -51,7 +57,9 @@ exports.getAll = function (isAll, cached, callback) { categories.unshift(cateAll); categories.push(cateOther); } + //从数据库中读到数据 if (categories) { + //将数据塞入缓存 redisClient.setItem(cache_key, categories, redisClient.defaultExpired, function (err) { if (err) { return callback(err); @@ -190,4 +198,4 @@ exports.save = function (array, callback) { } }); }); -}; \ No newline at end of file +};