mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-27 22:46:04 +00:00
use cacheTimestamp
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
$(function () {
|
||||
var app = new Espo.App({
|
||||
useCache: true,
|
||||
r: '@@timestamp'
|
||||
cacheTimestamp: {{cacheTimestamp}}
|
||||
}, function (app) {
|
||||
app.start();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user