opcode81 / sensAI

The Python library for sensible AI.
https://opcode81.github.io/sensAI/docs/
Other
40 stars 3 forks source link

Add InMemoryPersistentKeyValueCache #81

Closed MischaPanch closed 8 months ago

MischaPanch commented 8 months ago

I was surprised not to find this (although in-memory is kinda colliding with "Persistent").

It's going to very useful for me since I'll be reusing cached ColumnGenerators across multiple VectorModels, so an in-memory cache is appropriate.

Do you agree that this would be a useful extension? @opcode81

opcode81 commented 8 months ago

I agree. The reason it doesn't exist is, as always, that we haven't had a use for it yet...

To deal with the naming issue, we should add KeyValueCache, which shall be what PersistentKeyValueCache is now, and PersistentKeyValueCache can just inherit from it with pass for now; maybe we'll find useful stuff to add to it later.

The new cache can then be InMemoryKeyValueCache(KeyValueCache).

We'll also want to change some interfaces to use KeyValueCache rather than PersistentCacheValueCache. Maybe it's easiest to start with a rename of PersistentKeyValueCache, as this will update all references, and then reintroduce it only in module cache.

MischaPanch commented 8 months ago

Cool, I'll make a PR