[odb-users] Custom session example code (in test project)

Boris Kolpackov boris at codesynthesis.com
Mon Jun 23 03:09:10 EDT 2014


Hi Alessandro,

Alessandro Bellina <abellina at gmail.com> writes:

> My question is, if I just want a session that stores objects for me, such
> that I can find them by key later on... and I don't care about the change
> tracking, do I need to worry about flushing?

No, you don't. The interface that should be provided by a custom
session is described in Section 11.2, "Custom Sessions". In
particular:

"The notification functions are called after an object has been persisted,
 loaded, updated, or erased, respectively. If your session implementation
 does not need some of the notifications, you still have to provide their
 functions, however, you can leave their implementations empty."

You can also use the default odb::session implementation from libodb as
a guide. It only implements the object cache functionality and, as you
will see, has most of the notification functions do nothing. BTW, this
implementation allows low-level access to the cache (see the "Low-level
object cache access (iteration, etc)." section of the class) so maybe
you could reuse this implementation.

Boris



More information about the odb-users mailing list