Classes
Global | Description |
---|---|
CacheEntry | CacheEntry |
Functions
Global | Description |
---|---|
free(byTTL) | 从缓存中释放资源。 Frees the resource from cache. |
allocate() ⇒ CacheEntry | 在缓存中分配资源。 Allocates the resource in cache. |
setTimeToLive(ticks, seconds) ⇒ CacheEntry | 设置缓存条目的生存时间。 Sets the time to live for the cache entry. |
isStillAlive() ⇒ Boolean | 检查缓存条目是否仍然有效(未过期)。 Checks whether the cache entry is still alive (not expired). |
touch() | 确保资源不会被生存时间释放。如果资源已经被TTL释放,则重新放入缓存。 Makes sure that resource won't be freed by Time To Live. If resource was already freed by TTL, put it in cache again. |
CacheEntry
CacheEntry
Kind: global class
new CacheEntry(cache, key, item)
资源类。如果在一段时间或滴答数内未使用,则允许被垃圾回收。
The resource class. Allows to be collected as a garbage if not use for some time or ticks.
Param | Type | Description |
---|---|---|
cache | Object | 缓存管理器 - The cache manager |
key | String | 资源的 URL - URL of the resource |
item | Object | 要存储在缓存中的项目 - Bitmap, HTML5Audio, WebAudio - whatever you want to store in the cache |
free(byTTL)
从缓存中释放资源。
Frees the resource from cache.
Kind: global function
Param | Type | Description |
---|---|---|
byTTL | Boolean | 是否通过 TTL 释放资源 - Whether the resource is freed by TTL |
allocate() ⇒ CacheEntry
在缓存中分配资源。
Allocates the resource in cache.
Kind: global function
Returns: CacheEntry
- 返回此缓存条目 - Returns this cache entry
setTimeToLive(ticks, seconds) ⇒ CacheEntry
设置缓存条目的生存时间。
Sets the time to live for the cache entry.
Kind: global function
Returns: CacheEntry
- 返回此缓存条目 - Returns this cache entry
Param | Type | Description |
---|---|---|
ticks | Number | 滴答时间 TTL,未设置时为 0 - TTL in ticks, 0 if not set |
seconds | Number | 秒数 TTL,未设置时为 0 - TTL in seconds, 0 if not set |
isStillAlive() ⇒ Boolean
检查缓存条目是否仍然有效(未过期)。
Checks whether the cache entry is still alive (not expired).
Kind: global function
Returns: Boolean
- 如果缓存条目仍然有效则返回 true - True if the cache entry is still alive
touch()
确保资源不会被生存时间释放。如果资源已经被 TTL 释放,则重新放入缓存。
Makes sure that resource won't be freed by Time To Live.
If resource was already freed by TTL, put it in cache again.
Kind: global function