mirror of
https://github.com/lkeme/BiliHelper-personal.git
synced 2025-12-19 09:30:10 +08:00
[fix] Cache fixes #114
This commit is contained in:
parent
af37f769d7
commit
5908419c38
2
.gitignore
vendored
2
.gitignore
vendored
@ -26,13 +26,13 @@ conf/user1.ini
|
|||||||
/conf/user.ini
|
/conf/user.ini
|
||||||
/conf/test.ini
|
/conf/test.ini
|
||||||
/conf/test1.ini
|
/conf/test1.ini
|
||||||
/log/
|
|
||||||
/src/backup/
|
/src/backup/
|
||||||
script.php
|
script.php
|
||||||
|
|
||||||
# ignore all files in lib/
|
# ignore all files in lib/
|
||||||
task/*
|
task/*
|
||||||
cache/*
|
cache/*
|
||||||
|
log/*
|
||||||
# except for .gitkeep
|
# except for .gitkeep
|
||||||
!.gitkeep
|
!.gitkeep
|
||||||
# ignore TODO file in root directory,not subdir/TODO
|
# ignore TODO file in root directory,not subdir/TODO
|
||||||
|
|||||||
3
log/.gitkeep
Normal file
3
log/.gitkeep
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file !.gitkeep
|
||||||
@ -36,11 +36,13 @@ class Cache
|
|||||||
if (!isset($this->caches[$classname])) {
|
if (!isset($this->caches[$classname])) {
|
||||||
// 如果不存在缓存 初始化 "BHP_username_APP.dat"
|
// 如果不存在缓存 初始化 "BHP_username_APP.dat"
|
||||||
$this->caches[$classname] = new Flintstone(
|
$this->caches[$classname] = new Flintstone(
|
||||||
'BHP_' . getConf('username', 'login.account') . '_' . $classname, [
|
$this->removeSpecStr('BHP_' . getConf('username', 'login.account') . '_' . $classname),
|
||||||
'dir' => APP_CACHE_PATH,
|
[
|
||||||
'gzip' => true,
|
'dir' => APP_CACHE_PATH,
|
||||||
'formatter' => new JsonFormatter()
|
'gzip' => true,
|
||||||
]);
|
'formatter' => new JsonFormatter()
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->cache = $this->caches[$classname];
|
$this->cache = $this->caches[$classname];
|
||||||
return $this;
|
return $this;
|
||||||
@ -72,7 +74,6 @@ class Cache
|
|||||||
return $this->load($classname);
|
return $this->load($classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @use 获取值
|
* @use 获取值
|
||||||
* @param string $key
|
* @param string $key
|
||||||
@ -99,4 +100,20 @@ class Cache
|
|||||||
// $users->set('bob', ['email' => 'bob@site.com', 'password' => '123456']);
|
// $users->set('bob', ['email' => 'bob@site.com', 'password' => '123456']);
|
||||||
$this->getClassObj($extra_name)->cache->set($key, $data);
|
$this->getClassObj($extra_name)->cache->set($key, $data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @use 去除特殊符号
|
||||||
|
* @param string $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function removeSpecStr(string $data): string
|
||||||
|
{
|
||||||
|
$specs = str_split(".,:;'*?~`!@#$%^&+=)(<>{}]|\/、");
|
||||||
|
foreach ($specs as $spec) {
|
||||||
|
$data = str_replace($spec, '', $data);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file !.gitkeep
|
||||||
Loading…
Reference in New Issue
Block a user