[odb-users] Creation of ODB cache

Davide Anastasia Davide.Anastasia at qualitycapital.com
Wed May 30 05:41:22 EDT 2012


Thanks Boris,
I had a look at the manual. I have a few questions on that:

1. can a session object be a member of a class? I'm saying that because
my class essentially runs into an std::thread and waits for "updates" to
store, starting a transaction every time:

void run()
{
	while (1)
	{
		// wait
		Transaction t( ...) ;

		// load, persist, ?

		t.commit();
	}
}

2. how many session object can my application have? Can it make sense to
have a session at the beginning of the application as "master" session?
3. If I do a conditional search, is the retrieved object stored in the
session?
4. Does session apply to Views?

To many questions, I know :)

Best,
Davide


-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: 30 May 2012 10:13
To: Davide Anastasia
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] Creation of ODB cache

Hi Davide,

Davide Anastasia <Davide.Anastasia at qualitycapital.com> writes:

> I'm trying to create a cache of ODB objects: these objects are stored 
> into this map<key, value> and will be retrieved for the map instead 
> than the database when already available.
> 
> Does anything like exist already in ODB?

Yes, it is called session and the key is the object id. One big
advantage of the session compared to a custom cache is that it is
integrated with the database operations (e.g., persist(), load(),
erase(), etc). So, for example, if you call load() and the object is
already in the session, then it will be automatically returned without
any database access.

For more information, see Chapter 10, "Session" in the ODB manual.

Boris



More information about the odb-users mailing list