-
-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving eventDispatcher findListener call and settings repo
- Loading branch information
1 parent
177d514
commit ee79913
Showing
3 changed files
with
112 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Leantime\Domain\Setting\Services; | ||
|
||
use Illuminate\Support\Facades\Cache; | ||
|
||
class SettingCache | ||
{ | ||
private const CACHE_KEY_PREFIX = 'setting:'; | ||
private const CACHE_TTL = 3600; // 1 hour | ||
|
||
/** | ||
* Get setting from cache | ||
*/ | ||
public function get(string $key): mixed | ||
{ | ||
return Cache::get(self::CACHE_KEY_PREFIX . $key); | ||
} | ||
|
||
/** | ||
* Store setting in cache | ||
*/ | ||
public function set(string $key, mixed $value): void | ||
{ | ||
Cache::put(self::CACHE_KEY_PREFIX . $key, $value, self::CACHE_TTL); | ||
} | ||
|
||
/** | ||
* Remove setting from cache | ||
*/ | ||
public function forget(string $key): void | ||
{ | ||
Cache::forget(self::CACHE_KEY_PREFIX . $key); | ||
} | ||
|
||
/** | ||
* Clear all settings from cache | ||
*/ | ||
public function flush(): void | ||
{ | ||
Cache::tags(['settings'])->flush(); | ||
} | ||
} |