Re: Storing a dynahash for an entire connection or - Mailing list pgsql-hackers

From Neil Conway
Subject Re: Storing a dynahash for an entire connection or
Date
Msg-id 1164667500.23622.401.camel@localhost.localdomain
Whole thread Raw
In response to Re: Storing a dynahash for an entire connection or  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Storing a dynahash for an entire connection or  (Greg Mitchell <gmitchell@atdesk.com>)
List pgsql-hackers
On Mon, 2006-11-27 at 17:04 -0500, Andrew Dunstan wrote:
> Maybe I have misunderstood, but I don't see in this case how to 
> determine that the cached data is still valid.

Well, I was saying that if you want to cache something for the duration
of the current session, checking for the validity of the context of
allocation is moot, since you can just use a long-lived context.

If you want to cache stuff for the duration of a transaction, one
technique would be to maintain the cache in a child of TopMemoryContext,
stamp the cache data with the XID that created it, and then use the XID
to decide when to invalidate cached data.

Note that regardless of the memory context that is used, implementing
correct transactional behavior is non-trivial: the int2 -> text mapping
will still be incorrect in the face of changes to the mapping table by
your own transaction (or another committed txn, in the case of read
committed). From Greg's description I guessed that a session-length
cache was what he needed anyway...

-Neil




pgsql-hackers by date:

Previous
From: Devrim GUNDUZ
Date:
Subject: Re: Shared pg_xlog directory/partition and warm standby
Next
From: Tom Lane
Date:
Subject: Re: [PATCHES] doc patch for savepoints