Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support LRU for audio cache nodes #14

Closed
parente opened this Issue · 3 comments

1 participant

@parente
Owner

Number of audio nodes in memory can grow without bound. Allow app to specify maximum number and implement a LRU strategy.

@parente
Owner

Can impl using doubly-linked list, hash, and hash/list size count where hash tracks cache key -> pointer to node and where head of list is most recently used, tail is least recently used. Use / reuse means moving a node to the head of the list, O(1). When the cache size grows larger than the desired, the tail is popped off, O(1). Look-up is O(1) in the map.

Serialization requires a O(N) walk over the list storing all keys and node data in an ordered array. Unserialization requires rebuilding the linked list, map, and total count from the array.

@parente
Owner

Not clear what should be tracked for deletion or how using the technique above.

  • _speechCache - JS object with speech props ready for mixin on an audio node
  • _soundCache - Same as above but for a sound
  • _speechRenderings - Deferred for in-flight speech synch requests
  • _speechFiles - JSON encoded server response for speech synth, persisted in localStorage
@parente
Owner

_speechFiles is the only data persisted. This is what should be tracked. When an item in that cache becomes stale, it should also cause the removal of the item from _speechCache.

_soundCache should probably go away entirely. We're not caching real audio nodes anymore.

@parente parente referenced this issue from a commit
@parente parente Issue #14, integrate lru tracking
* Remove sound object cache
* Remove speech object cache
* Load/save lru cache in local storage
* Existing tests seem ok, but needs more testing
ee382f1
@parente parente referenced this issue from a commit
@parente parente Issue #14, persist test with fixes
* Fix read from cache
* Update lru info on hit in cache
* Fix cache cleanup
* Better test cleanup
dc88df3
@parente parente closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.