rhelgeby / smprojectbase

Automatically exported from code.google.com/p/smprojectbase
0 stars 0 forks source link

Cache for objectlib #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Objects may be too slow in certain situations and a solution for caching an 
object into an enumerated array would be useful. These can of course be made 
manually, but an automated generic solution would help, since this code would 
be repeated a lot.

The cache is just a front-end for the object library and should be independent 
of internal stuff. It should only use object reflection and accessor functions.

From object to cache:
* Declare an enumerated array with matching data types.
* Provide a user callback for converting a key name into an index in the array.
* Call the cache function. It will loop through keys in the object, look up 
which index to use and copy it to the array.

From cache to object:
* Provide a user callback for converting an array index into a key name.
* Call the update function. It will loop through the array, look up key names 
and store values. This implies validation.

Since the callback must be generic we won't benefit from tag checks (the array 
must have the "any" tag). The cache solution has to trust the callbacks to give 
correct indexes and key names, which might be a potential source of bugs if 
data structure is changed. Using symbols (variables) rather than hard coded 
values would be highly recommended.

Original issue reported on code.google.com by richard.helgeby@gmail.com on 22 Apr 2013 at 8:16

GoogleCodeExporter commented 9 years ago
Instead of a callback for getting individual key names and indexes. Use a 
callback for mapping a bunch of keys at the same time, so that the cache can 
have it's own key mapping cache.

Original comment by richard.helgeby@gmail.com on 24 Apr 2013 at 7:46

GoogleCodeExporter commented 9 years ago
Another concern is when you cache an entire object and then modify both the 
cache and keys in the object. Flushing the cache will overwrite the object.

We might need support for caching only certain keys instead of the whole object.

Original comment by richard.helgeby@gmail.com on 24 Apr 2013 at 7:51

GoogleCodeExporter commented 9 years ago

Original comment by richard.helgeby@gmail.com on 23 Dec 2013 at 6:34

GoogleCodeExporter commented 9 years ago
Note:
When creating a plugin that use objectlib and caching, it should provide a way 
to disable the cache and use direct object access for debugging purposes.

Original comment by richard.helgeby@gmail.com on 10 Mar 2014 at 7:38