Skip to content

Commit

Permalink
fix: 修复缓存异常
Browse files Browse the repository at this point in the history
  • Loading branch information
三少 committed Nov 10, 2023
1 parent 0df6c25 commit 7f44fd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/cache/src/h5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function <
key: T,
): Partial<Cache.StateOpt<Cache.ICacheOptAll<TRam, TLocal>>>[T] {
if (tempKeys.includes(key as keyof TRam)) {
return store[key] || init.ram[key as keyof TRam]
return store[key] ?? init.ram[key as keyof TRam]
} else if (localKeys.includes(key as keyof TLocal)) {
let value = store[key]
if (isUndefined(value) || isNull(value)) {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function <
}): Promise<Partial<Cache.StateOpt<Cache.ICacheOptAll<TRam, TLocal>>>[T]> {
return new Promise(function (resolve) {
if (tempKeys.includes(option.key as keyof TRam)) {
resolve(store[option.key] || init.ram[option.key as keyof TRam])
resolve(store[option.key] ?? init.ram[option.key as keyof TRam])
} else if (localKeys.includes(option.key as keyof TLocal)) {
let value = store[option.key]
if (isUndefined(value) || isNull(value)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cache/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function <
key: T,
): Partial<Cache.StateOpt<Cache.ICacheOptAll<TRam, TLocal>>>[T] {
if (tempKeys.includes(key as keyof TRam)) {
return store[key] || init.ram[key as keyof TRam]
return store[key] ?? init.ram[key as keyof TRam]
} else if (localKeys.includes(key as keyof TLocal)) {
let value = store[key]
if (isUndefined(value) || isNull(value)) {
Expand Down Expand Up @@ -87,7 +87,7 @@ export default function <
}): Promise<Partial<Cache.StateOpt<Cache.ICacheOptAll<TRam, TLocal>>>[T]> {
return new Promise(function (resolve) {
if (tempKeys.includes(option.key as keyof TRam)) {
resolve(store[option.key] || init.ram[option.key as keyof TRam])
resolve(store[option.key] ?? init.ram[option.key as keyof TRam])
} else if (localKeys.includes(option.key as keyof TLocal)) {
const value = store[option.key]
if (isUndefined(value) || isNull(value)) {
Expand Down

0 comments on commit 7f44fd7

Please # to comment.