comemo icon indicating copy to clipboard operation
comemo copied to clipboard

MVP serialize

Open astrale-sharp opened this issue 1 year ago • 0 comments

Howdy, this is a very minimal implementation of which the design must be discussed:

# How it works: It registers serialization and de-serialization functions at declaration time and provides the serialization implementation.

You can retrieve a blob of data using comemo::serialize() and replace your current caches using comemo::deserialize

It needs a unique ID per function, currently it's a String using the module_path, file name and line but small performance could be gained by hashing it. (It's not using the name because syn current parsing provide a function item which is nameless)

What I like:

  • It works
  • It's not super complex

What I like less:

  • hard codes the serialization implementation (bincode), not necessarily a big deal but we should at least ensure it's the most efficient one
  • exposes CacheData via inner() method which is a possible foot-gun for users (it's doc(hidden) so I feel like it's their responsibility)
  • To enable it per function, you need to add the serialize attribute, I think we should assume serialization and provide instead a no serialize option
  • No way to measure how much data is useful, silently ignores incorrect data

astrale-sharp avatar Apr 09 '24 15:04 astrale-sharp