Skip to content

Commit

Permalink
= 4.2.7.4 =
Browse files Browse the repository at this point in the history
~ Tweak cache UserModel.
  • Loading branch information
tungnxt89 committed Nov 26, 2024
1 parent a7abac0 commit d5ed349
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions inc/Models/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function map_to_object( $data ): UserModel {
public static function find( int $user_id, bool $check_cache = false ) {
$filter_user = new LP_User_Filter();
$filter_user->ID = $user_id;
$key_cache = "user-model/find/id/{$user_id}";
$key_cache = "userModel/find/id/{$user_id}";
$lp_course_cache = new LP_Cache();

// Check cache
Expand Down Expand Up @@ -458,7 +458,10 @@ public function get_profile_social( int $user_id = 0 ): array {
* @version 1.0.0
*/
public function save(): UserModel {
$this->clean_caches();
// Update cache
$key_cache = "userModel/find/id/{$this->get_id()}";
$lp_course_cache = new LP_Cache();
$lp_course_cache->set_cache( $key_cache, $this );

return $this;
}
Expand All @@ -470,7 +473,7 @@ public function save(): UserModel {
*/
public function clean_caches() {
// Clear cache.
$key_cache = "user-model/find/id/{$this->get_id()}";
$key_cache = "userModel/find/id/{$this->get_id()}";
$lp_course_cache = new LP_Cache();
$lp_course_cache->clear( $key_cache );
}
Expand Down

0 comments on commit d5ed349

Please sign in to comment.