Skip to content

Commit

Permalink
checkexists
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 7, 2018
1 parent d29133d commit 91dde36
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/BaseModel.php
Expand Up @@ -21,7 +21,7 @@ public static function is_success(){
* @return bool
*/
public static function checkIdExist($id, $status = 'normal_status_arr'){
$redis_key = 'checkIdExist_id_'.$id;
$redis_key = static::class.'_checkIdExist_id_'.$id;
$redis_key = self::query_flag_field_for_redis_key($redis_key);

$result = static::redis($redis_key,static::checkExist('id',$id,self::is_set_status($status)));
Expand Down Expand Up @@ -50,7 +50,7 @@ public static function checkIdExistSimple($id){
* @return bool
*/
public static function checkNameExist($name, $status = 'normal_status_arr'){
$redis_key = 'checkIdExist_name_'.$name;
$redis_key = static::class.'_checkIdExist_name_'.$name;
$redis_key = self::query_flag_field_for_redis_key($redis_key);

$result = static::redis($redis_key,static::checkExist('name',$name,self::is_set_status($status),[],['id']));
Expand Down Expand Up @@ -83,7 +83,7 @@ public static function checkNameExistSimple($name){
* @return bool
*/
public static function checkFieldExist($field, $value, $status = 'normal_status_arr', $other_where = [], $return_field = []){
$redis_key = 'checkFieldExist_'.$field.'_'.$value;
$redis_key = static::class.'_checkFieldExist_'.$field.'_'.$value;
$redis_key = self::query_flag_field_for_redis_key($redis_key);

$result = static::redis($redis_key,static::checkExist($field, $value, self::is_set_status($status), $other_where, array_merge(['id'],$return_field)));
Expand Down Expand Up @@ -150,6 +150,8 @@ public static function put($id = 0, array $value, $unset_empty_keys = true){

if ($result = self::basePut(['id'=>$id], $value)){
self::RedisFlushByKey(self::query_flag_field_for_redis_key(static::class.'_lists').'*');
self::RedisFlushByKey(self::query_flag_field_for_redis_key(static::class.'_checkIdExist_id_').$id.'*');
self::RedisFlushByKey(self::query_flag_field_for_redis_key(static::class.'_checkFieldExist_').'*');
self::RedisFlushByKey(self::query_flag_field_for_redis_key(static::class.'_id_'.$id).'*');
self::RedisFlushByKey(self::query_flag_field_for_redis_key(static::class.'_field_value').'*');
return $result;
Expand Down

0 comments on commit 91dde36

Please sign in to comment.