Maslosoft / Mangan

MongoDB Object Persister/ODM
https://maslosoft.com/mangan/
Other
5 stars 0 forks source link

Cache DBRefs/Related #69

Open pmaselkowski opened 8 years ago

pmaselkowski commented 8 years ago

Possibly this could be done with WeakMap.

So that found instance could be added to WeakSet (by id or class+id), then reused without querying DB.

When updating this object should be removed from WeakMap - and then re-fetched when needed. Problems:

  1. When doing mass-updates by criteria - no way to detect which were updated
  2. Require additional extension - this could be remedied by optionality mentioned below

Cache behavior could be affected by annotation, as sometimes this behavior is acceptable.

Possible annotations syntax:

@DbRef(MyClass, cached = true)

Best way to implement this would be through plugins. So updateable feature could be also refactored as plugin.