修改缓存方式为文件缓存
parent
ba25d33f99
commit
f77109be52
11
index.js
11
index.js
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* nodeJS 模板引擎(依赖doJS框架)
|
||||
* nodeJS 模板引擎
|
||||
* @authors yutent (yutent@doui.cc)
|
||||
* @date 2015-12-28 13:57:12
|
||||
*
|
||||
|
@ -10,6 +10,7 @@ require('es.shim')
|
|||
|
||||
const Tool = require('./lib/tool')
|
||||
const path = require('path')
|
||||
const fs = require('iofs')
|
||||
|
||||
function hash(str) {
|
||||
return Buffer.from(str).toString('hex')
|
||||
|
@ -76,20 +77,22 @@ class Smarty {
|
|||
key = hash(tpl)
|
||||
|
||||
if (this.__CACHE__[key]) {
|
||||
return Promise.resolve(this.__CACHE__[key])
|
||||
return Promise.resolve(fs.cat(path.resolve('./cache/', key)))
|
||||
}
|
||||
|
||||
cache = this.tool.__readFile__(tpl, noParse)
|
||||
|
||||
if (noParse) {
|
||||
this.__CACHE__[key] = cache
|
||||
this.__CACHE__[key] = true
|
||||
fs.echo(cache, path.resolve('./cache/', key))
|
||||
return Promise.resolve(cache)
|
||||
}
|
||||
|
||||
try {
|
||||
cache = this.tool.parse(cache, this.__DATA__)
|
||||
if (this.opt.cache) {
|
||||
this.__CACHE__[key] = cache
|
||||
this.__CACHE__[key] = true
|
||||
fs.echo(cache, path.resolve('./cache/', key))
|
||||
}
|
||||
return Promise.resolve(cache)
|
||||
} catch (err) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "smartyx",
|
||||
"version": "1.3.1",
|
||||
"version": "1.4.0",
|
||||
"description": "nodeJS模板引擎,理念源自于PHP的smarty模板引擎",
|
||||
"keywords": ["fivejs", "smarty", "template", "ejs", "jade"],
|
||||
"author": "宇天 <yutent@doui.cc>",
|
||||
|
|
Loading…
Reference in New Issue