mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Some experiments with a cache control thing. [skip ci]
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace FireflyIII\Support;
|
||||
|
||||
|
||||
use Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class ChartProperties
|
||||
@@ -24,6 +26,8 @@ class ChartProperties
|
||||
public function __construct()
|
||||
{
|
||||
$this->properties = new Collection;
|
||||
$this->addProperty(Auth::user()->id);
|
||||
$this->addProperty(Preferences::lastActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,25 +45,33 @@ class ChartProperties
|
||||
public function md5()
|
||||
{
|
||||
$string = '';
|
||||
//Log::debug('--- building string ---');
|
||||
foreach ($this->properties as $property) {
|
||||
|
||||
if ($property instanceof Collection || $property instanceof EloquentCollection) {
|
||||
$string .= print_r($property->toArray(), true);
|
||||
// Log::debug('added collection (size=' . $property->count() . ')');
|
||||
continue;
|
||||
}
|
||||
if ($property instanceof Carbon) {
|
||||
$string .= $property->toRfc3339String();
|
||||
// Log::debug('Added time: ' . $property->toRfc3339String());
|
||||
continue;
|
||||
}
|
||||
if (is_object($property)) {
|
||||
$string .= $property->__toString();
|
||||
// Log::debug('Added object of class ' . get_class($property));
|
||||
}
|
||||
if (is_array($property)) {
|
||||
$string .= print_r($property, true);
|
||||
// Log::debug('Added array (size=' . count($property) . ')');
|
||||
}
|
||||
$string .= (string)$property;
|
||||
// Log::debug('Added cast to string: ' . $property);
|
||||
}
|
||||
|
||||
// Log::debug('--- done building string ---');
|
||||
|
||||
return md5($string);
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ namespace FireflyIII\Support;
|
||||
|
||||
use Auth;
|
||||
use FireflyIII\Models\Preference;
|
||||
|
||||
use Log;
|
||||
/**
|
||||
* Class Preferences
|
||||
*
|
||||
@@ -12,6 +12,25 @@ use FireflyIII\Models\Preference;
|
||||
*/
|
||||
class Preferences
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function lastActivity()
|
||||
{
|
||||
$preference = $this->get('lastActivity', microtime())->data;
|
||||
|
||||
return md5($preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function mark() {
|
||||
Log::debug('MARK!');
|
||||
$this->set('lastActivity',microtime());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param null $default
|
||||
|
Reference in New Issue
Block a user