扩大内存和文件缓存的限制和默认值

Signed-off-by: madixin <madixin@huawei.com>
This commit is contained in:
madixin 2024-12-21 18:25:32 +08:00
parent fc6668cb0d
commit 2f2e562aed
3 changed files with 17 additions and 23 deletions

View File

@ -2,6 +2,7 @@
- Successful callback returns httpCode
- Fix bug: Network error code httpCode returns no data
- Fix bug: Height adaptation leads to fixed component height
- modify memory cache limit and file cache limit
## 3.2.0-rc.6
- Support LogUtil to turn off log

View File

@ -16,7 +16,6 @@ import util from '@ohos.util';
import { FileUtils } from '../utils/FileUtils';
import fs from '@ohos.file.fs';
import { LogUtil } from '../utils/LogUtil';
import { SparkMD5 } from '../3rd_party/sparkmd5/spark-md5';
const INT_MAX = 2147483647
/**
@ -33,24 +32,21 @@ export class FileCache {
private lruCache: util.LRUCache<string, number>
private isInited: boolean = false
private context?: Context
readonly defaultMaxSize: number = 512;
readonly defaultSize: number = INT_MAX;
readonly defaultMaxMemorySize: number = 512 * 1024 * 1024;
readonly defaultMemorySize: number = 128 * 1024 * 1024;
readonly defaultMaxMemorySize: number = 10 * 1024 * 1024 * 1024;
readonly defaultMemorySize: number = 1024 * 1024 * 1024;
constructor(context: Context, size: number, memory: number) {
if (size <= 0 || size > INT_MAX) {
size = this.defaultSize
size = INT_MAX;
}
if (memory <= 0 || memory > this.defaultMaxMemorySize) {
memory = this.defaultMemorySize
memory = this.defaultMemorySize;
}
this.lruCache = new util.LRUCache(size);
this.maxMemory = memory
this.maxMemory = memory;
this.currentMemory = 0;
this.maxSize = size
this.context = context
this.maxSize = size;
this.context = context;
}
/**
@ -204,8 +200,6 @@ export class FileCache {
for (let i = 0; i < filenames.length; i++) {
await FileUtils.getInstance().deleteFile(this.path + filenames[i])
}
this.isInited = true
}
size(): number {

View File

@ -21,23 +21,23 @@ export class MemoryLruCache implements IMemoryCache {
currentMemory: number = 0
maxSize: number = 0
private lruCache: util.LRUCache<string, ImageKnifeData>
readonly defaultMaxSize: number = 4096
readonly defaultSize: number = 512
readonly defaultMaxMemorySize: number = 1024 * 1024 * 1024
readonly defaultMemorySize: number = 128 * 1024 * 1024
readonly defaultMaxSize: number = 65536;
readonly defaultSize: number = 512;
readonly defaultMaxMemorySize: number = 10 * 1024 * 1024 * 1024;
readonly defaultMemorySize: number = 1024 * 1024 * 1024;
constructor(size: number, memory: number) {
if (size <= 0 || size > this.defaultMaxSize) {
size = this.defaultSize
size = this.defaultSize;
}
if (memory <= 0 || memory > this.defaultMaxMemorySize) {
memory = this.defaultMemorySize
memory = this.defaultMemorySize;
}
this.lruCache = new util.LRUCache(size);
this.maxMemory = memory
this.maxSize = size
this.currentMemory = 0
this.maxMemory = memory;
this.maxSize = size;
this.currentMemory = 0;
}
// 添加缓存键值对
@ -117,7 +117,6 @@ export class MemoryLruCache implements IMemoryCache {
this.currentMemory -= value.source.getPixelBytesNumber();
// value.source.release()
}
// LogUtil.info('MemoryCache removeMemorySize: ' + value.source.getPixelBytesNumber() + ' currentMemory' + this.currentMemory)
}
}