Save value instead of raw model to cache

This commit is contained in:
Miguel Nogueira 2021-01-06 01:02:47 +00:00
parent 2ec2a92645
commit baddf3fc76
Signed by: miguel456
GPG Key ID: 2CF61B825316C6A0
2 changed files with 4 additions and 3 deletions

View File

@ -31,13 +31,14 @@ class Options
{ {
$value = Cache::get($option); $value = Cache::get($option);
if (is_null($value)) { if (is_null($value)) {
Log::debug('Option '.$option.'not found in cache, refreshing from database'); Log::debug('Option '.$option.'not found in cache, refreshing from database');
$value = Option::where('option_name', $option)->first(); $value = Option::where('option_name', $option)->first();
if (is_null($value)) { if (is_null($value)) {
throw new \Exception('This option does not exist.'); throw new \Exception('This option does not exist.');
} }
Cache::put($option, $value); Cache::put($option, $value->option_value);
Cache::put($option.'_desc', 'Undefined description'); Cache::put($option.'_desc', 'Undefined description');
return $value->option_value; return $value->option_value;

View File

@ -47,7 +47,7 @@
<div class="col"> <div class="col">
<div class="alert alert-warning alert-dismissible fade show" role="alert"> <div class="alert alert-warning alert-dismissible fade show" role="alert">
<i class="fas fa-info-circle"></i> <b>Available security policies</b> <i class="fas fa-info-circle"></i> <b>Available security policies</b> (current policy: {{ $security['secPolicy'] }})
<p><b>Disabled:</b> No security policy will be enforced. This is insecure.</p> <p><b>Disabled:</b> No security policy will be enforced. This is insecure.</p>
@ -166,7 +166,7 @@
<div class="form-group"> <div class="form-group">
<label for="pwExpiry">Password Expiry Control</label> <label for="pwExpiry">Password Expiry Control</label>
<input type="text" class="form-control" id="pwExpiry" placeholder="time in days" name="pwExpiry" value="{{ $security['pwExpiry'] }}"> <input type="text" class="form-control" id="pwExpiry" placeholder="time in days" name="pwExpiry" value="{{ $security['pwExpiry'] }}">
<p class="text-muted text-sm"><i class="fas fa-info-circle"></i> Leave this field blank to disable. Users will be forced to reset their password after the specified time.</p> <p class="text-muted text-sm"><i class="fas fa-info-circle"></i> Leave this field zeroed to disable. Users will be forced to reset their password after the specified time.</p>
</div> </div>