Support LRU for audio cache nodes #14

Closed
parente opened this Issue Apr 27, 2010 · 3 comments

1 participant

@parente
UNC Open Web Group member

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

@parente
UNC Open Web Group member

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
UNC Open Web Group member

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
UNC Open Web Group member

_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 added a commit that referenced this issue Jul 17, 2011
@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 added a commit that referenced this issue Jul 17, 2011
@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 Jul 18, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment