图片缓存

This commit is contained in:
2025-05-20 09:26:59 +08:00
parent b057b42c4d
commit 1ccf8354a9
3 changed files with 97 additions and 2 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace app\process;
use app\controller\FeishuController;
use app\model\Customer;
use app\model\CustomerHis;
use app\model\FeishuUser;
use app\model\User;
use app\model\Vehicle;
use app\service\OssService;
use support\Cache;
use support\Log;
use Webman\App;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
// 每半小时执行一次
new Crontab('*/10 6 * * *', function(){
echo date('Y-m-d H:i:s') . "\n";
Log::info('img cache start',[time()]);
$vehicles = Vehicle::get();
$ossservice = new OssService();
foreach ($vehicles as $vehicle) {
$img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400);
Cache::set('img_dibai_'.$vehicle->id, $img_url, 86390);
}
Log::info('img cache end',[time()]);
});
}
}
+2 -1
View File
@@ -34,7 +34,8 @@
"shopwwi/webman-filesystem": "^1.1",
"shopwwi/filesystem-oss": "^1.0",
"webman/console": "^2.1",
"webman/cache": "^2.1"
"webman/cache": "^2.1",
"workerman/crontab": "^1.0"
},
"suggest": {
"ext-event": "For better performance. "
Generated
+57 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f6e35a2675e1ce0c8495ad470f4e9ecd",
"content-hash": "2dc28180e70f613eb100a93e80076a5e",
"packages": [
{
"name": "aliyuncs/oss-sdk-php",
@@ -5441,6 +5441,62 @@
},
"time": "2025-02-17T03:34:21+00:00"
},
{
"name": "workerman/crontab",
"version": "v1.0.7",
"source": {
"type": "git",
"url": "https://github.com/walkor/crontab.git",
"reference": "74f51ca8204e8eb628e57bc0e640561d570da2cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/walkor/crontab/zipball/74f51ca8204e8eb628e57bc0e640561d570da2cb",
"reference": "74f51ca8204e8eb628e57bc0e640561d570da2cb",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.0",
"workerman/workerman": ">=4.0.20"
},
"type": "library",
"autoload": {
"psr-4": {
"Workerman\\Crontab\\": "./src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "walkor",
"email": "walkor@workerman.net",
"homepage": "http://www.workerman.net",
"role": "Developer"
}
],
"description": "A crontab written in PHP based on workerman",
"homepage": "http://www.workerman.net",
"keywords": [
"crontab"
],
"support": {
"email": "walkor@workerman.net",
"forum": "http://wenda.workerman.net/",
"issues": "https://github.com/walkor/workerman/issues",
"source": "https://github.com/walkor/crontab",
"wiki": "http://doc.workerman.net/"
},
"time": "2025-01-15T07:20:50+00:00"
},
{
"name": "workerman/webman-framework",
"version": "v2.1.2",