jfinal enjoy 3.5
This commit is contained in:
@@ -105,7 +105,7 @@ public class ClassPathSource implements ISource {
|
||||
return finalFileName;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
public String getCacheKey() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ public class FileSource implements ISource {
|
||||
return lastModified != new File(finalFileName).lastModified();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
public String getCacheKey() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
@@ -27,12 +27,12 @@ public interface ISource {
|
||||
boolean isModified();
|
||||
|
||||
/**
|
||||
* key used to cache, return null if do not cache the template
|
||||
* cache key used to cache, return null if do not cache the template
|
||||
*
|
||||
* 注意:如果不希望缓存从该 ISource 解析出来的 Template 对象
|
||||
* 让 getKey() 返回 null 值即可
|
||||
* 让 getCacheKey() 返回 null 值即可
|
||||
*/
|
||||
String getKey();
|
||||
String getCacheKey();
|
||||
|
||||
/**
|
||||
* content of ISource
|
||||
|
@@ -25,7 +25,7 @@ import com.jfinal.template.EngineConfig;
|
||||
*/
|
||||
public class StringSource implements ISource {
|
||||
|
||||
private String key;
|
||||
private String cacheKey;
|
||||
private StringBuilder content;
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ public class StringSource implements ISource {
|
||||
throw new IllegalArgumentException("content can not be blank");
|
||||
}
|
||||
this.content = new StringBuilder(content);
|
||||
this.key = cache ? HashKit.md5(content) : null; // 不缓存只要将 key 值赋为 null 即可
|
||||
this.cacheKey = cache ? HashKit.md5(content) : null; // 不缓存只要将 cacheKey 值赋为 null 即可
|
||||
}
|
||||
|
||||
public StringSource(StringBuilder content, boolean cache) {
|
||||
@@ -46,15 +46,15 @@ public class StringSource implements ISource {
|
||||
throw new IllegalArgumentException("content can not be blank");
|
||||
}
|
||||
this.content = content;
|
||||
this.key = cache ? HashKit.md5(content.toString()) : null; // 不缓存只要将 key 值赋为 null 即可
|
||||
this.cacheKey = cache ? HashKit.md5(content.toString()) : null; // 不缓存只要将 cacheKey 值赋为 null 即可
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
public String getCacheKey() {
|
||||
return cacheKey;
|
||||
}
|
||||
|
||||
public StringBuilder getContent() {
|
||||
@@ -67,8 +67,8 @@ public class StringSource implements ISource {
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Key : ").append(key).append("\n");
|
||||
sb.append("Content : ").append(content).append("\n");
|
||||
sb.append("cacheKey : ").append(cacheKey).append("\n");
|
||||
sb.append("content : ").append(content).append("\n");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user