Skip to content

Commit

Permalink
feat: 缓存文件过期时间配置改为Duration #1302
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan committed Oct 19, 2023
1 parent 68ac868 commit 06a9422
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class StorageCredentialServiceImpl(
storageCredentials.apply {
cache = cache.copy(
loadCacheFirst = request.credentials.cache.loadCacheFirst,
expireDays = request.credentials.cache.expireDays,
expireDuration = request.credentials.cache.expireDuration
)
upload = upload.copy(localPath = request.credentials.upload.localPath)
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/devops-op/src/api/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ export function updateCredential(key, credential, defaultCredential = false) {
if (defaultCredential) {
const prefix = `${STORAGE_CONFIG_PREFIX}.${credential.type}`
const expireDaysKey = `${prefix}.${STORAGE_CACHE_CONFIG_PREFIX}.expireDays`
const expireDurationKey = `${prefix}.${STORAGE_CACHE_CONFIG_PREFIX}.expireDuration`
const loadCacheFirstKey = `${prefix}.${STORAGE_CACHE_CONFIG_PREFIX}.loadCacheFirst`
const values = [
{
'key': expireDaysKey,
'value': credential.cache.expireDays
},
{
'key': expireDurationKey,
'value': credential.cache.expireDuration * 1000 // consul上Duration不带单位时默认是毫秒
},
{
'key': loadCacheFirstKey,
'value': credential.cache.loadCacheFirst
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/devops-op/src/views/job/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
width="100"
>
<template slot-scope="scope">
{{scope.row.running ? "":""}}
{{ scope.row.running ? "":"" }}
</template>
</el-table-column>
<el-table-column
Expand Down
20 changes: 19 additions & 1 deletion src/frontend/devops-op/src/views/storage/Credential.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@
</template>
</el-table-column>
<el-table-column
label="缓存天数"
label="缓存天数(已废弃)"
width="180"
>
<template v-if="scope.row.cache.enabled" slot-scope="scope">
<span>{{ expireDays(scope.row.cache.expireDays) }}</span>
</template>
</el-table-column>
<el-table-column
label="缓存时间"
width="180"
>
<template v-if="scope.row.cache.enabled" slot-scope="scope">
<span>{{ formatSeconds(scope.row.cache.expireDuration) }}</span>
</template>
</el-table-column>
<el-table-column
label="优先读缓存"
width="180"
Expand Down Expand Up @@ -142,6 +150,16 @@ export default {
},
expireDays(expireDays) {
return parseInt(expireDays) <= 0 ? '永久' : expireDays
},
formatSeconds(seconds) {
if (seconds <= 0) {
return '永久'
}
const hours = Math.floor(seconds / 3600)
const minutes = Math.floor((seconds % 3600) / 60)
const remainingSeconds = seconds % 60
return `${hours}小时 ${minutes}分钟 ${remainingSeconds}`
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@
<el-form-item v-if="credential.cache.enabled" label="优先加载缓存" prop="cache.loadCacheFirst">
<el-switch v-model="credential.cache.loadCacheFirst" />
</el-form-item>
<el-form-item v-if="credential.cache.enabled" label="缓存天数" prop="cache.expireDays">
<el-form-item v-if="credential.cache.enabled" label="缓存天数(已废弃)" prop="cache.expireDays">
<el-input-number v-model="credential.cache.expireDays" controls-position="right" :min="0" :max="30" />
</el-form-item>
<el-form-item v-if="credential.cache.enabled" label="缓存时间(秒)" prop="cache.expireDuration">
<el-input-number v-model="credential.cache.expireDuration" controls-position="right" :min="0" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="close">取 消</el-button>
Expand Down

0 comments on commit 06a9422

Please sign in to comment.