use cacheTimestamp

This commit is contained in:
Yuri Kuznetsov
2014-04-16 15:15:03 +03:00
parent 5ee27cb060
commit 4343917a7d
5 changed files with 12 additions and 13 deletions

View File

@@ -62,15 +62,14 @@ class Config
return $this->fileManager;
}
/**
* Get an option from config
*
* @param string $name
* @param string $default
* @return string | array
*/
public function get($name)
public function get($name, $default = null)
{
$keys = explode('.', $name);
@@ -79,7 +78,7 @@ class Config
if (isset($lastBranch[$keyName]) && is_array($lastBranch)) {
$lastBranch = $lastBranch[$keyName];
} else {
return null;
return $default;
}
}
@@ -94,7 +93,7 @@ class Config
* @param string $value
* @return bool
*/
public function set($name, $value='')
public function set($name, $value = '')
{
if (is_array($name)) {
return $this->setArray($name);

View File

@@ -30,8 +30,8 @@ Espo.App = function (options, callback) {
if (this.useCache) {
this.cache = new Espo.Cache();
if (options.r) {
this.cache.handleActuality(options.r);
if (options.cacheTimestamp) {
this.cache.handleActuality(options.cacheTimestamp);
}
}

View File

@@ -26,15 +26,15 @@ Espo.Cache = Bull.Cacher.extend({
_prefix: 'espo-cache',
handleActuality: function (timestamp) {
var stored = this.get('app', 'timestamp');
handleActuality: function (cacheTimestamp) {
var stored = parseInt(this.get('app', 'cacheTimestamp'));
if (stored) {
if (stored != timestamp) {
if (stored !== cacheTimestamp) {
this.clear();
}
} else {
this.clear();
this.set('app', 'timestamp', timestamp);
this.set('app', 'cacheTimestamp', cacheTimestamp);
}
},

View File

@@ -11,7 +11,7 @@
$(function () {
var app = new Espo.App({
useCache: true,
r: '@@timestamp'
cacheTimestamp: {{cacheTimestamp}}
}, function (app) {
app.start();
});

View File

@@ -27,7 +27,7 @@ $app = new \Espo\Core\Application();
$app->isInstalled();
if (empty($_GET['entryPoint'])) {
include "main.html";
$app->runClient();
} else {
$app->runEntryPoint($_GET['entryPoint']);
}