Welcome! Log In Create A New Profile

Advanced

CLR Stored Procedure for Remove cache objects

Posted by Adi 
Adi
CLR Stored Procedure for Remove cache objects
October 02, 2009 12:10PM
All,
I am using memcached on windows server 2003 and using Be.IT memcached
client.

How can i remove cache object when any direct database change occur, i
want to invalidate / remove cache objects from memcached server, for
this i am thinking about the CLR stored procedure.

What if i write a trigger that activate on Update/Delete evetns and
call the CLR stored procedure to remove cache objects? somebody tried
this thing before?

Thanks
Henrik Schröder
Re: CLR Stored Procedure for Remove cache objects
October 02, 2009 01:10PM
In general, this is not the recommended usage of memcached. The best way is
to have an object relational mapper that you handle all database access
through and put your caching in that layer. That way you'll have cached
objects or lists of objects above it, and you should be able to do all
invalidations and updates in that layer.

You can of course do your invalidations in the database, but chances are
that you lack the bigger picture at that level, you won't know exactly which
data needs to be invalidated and what the cache keys for that data are.
Also, the higher you move your caching, the more complex and aggregated data
you can cache. Therefore, the general recommendation is to cache objects,
not database rows.

As for your actual question, I'm not familiar with calling .Net code from db
triggers, but how does it handle the runtime? Will the db only spawn one CLR
or multiple? The BeIT Memcached client has somewhat of a startup cost and it
has a connection pool, so it works best if the database only keeps one CLR
for all triggers.


/Henrik

On Fri, Oct 2, 2009 at 12:00, Adi <[email protected]> wrote:

>
> All,
> I am using memcached on windows server 2003 and using Be.IT memcached
> client.
>
> How can i remove cache object when any direct database change occur, i
> want to invalidate / remove cache objects from memcached server, for
> this i am thinking about the CLR stored procedure.
>
> What if i write a trigger that activate on Update/Delete evetns and
> call the CLR stored procedure to remove cache objects? somebody tried
> this thing before?
>
> Thanks
>
I got your point, i don't want to cache the table rows. please explain
"object relational mapper"?

But In my scenario i have some utility like Microsoft ILM that
synchronize user data from different system and i need to update or
invalidate cache after the user info updated.
for e.g.
if the user object is cached and database updated from the background
process than how can i invalidate/remove cache object that has the old
value? Is there any builtIn process to synchronize cache object from
database or i need to write my own routine like CLR stored procedure
etc.

On Oct 2, 5:06 pm, Henrik Schröder <skro...@gmail.com> wrote:
> In general, this is not the recommended usage of memcached. The best way is
> to have an object relational mapper that you handle all database access
> through and put your caching in that layer. That way you'll have cached
> objects or lists of objects above it, and you should be able to do all
> invalidations and updates in that layer.
>
> You can of course do your invalidations in the database, but chances are
> that you lack the bigger picture at that level, you won't know exactly which
> data needs to be invalidated and what the cache keys for that data are.
> Also, the higher you move your caching, the more complex and aggregated data
> you can cache. Therefore, the general recommendation is to cache objects,
> not database rows.
>
> As for your actual question, I'm not familiar with calling .Net code from db
> triggers, but how does it handle the runtime? Will the db only spawn one CLR
> or multiple? The BeIT Memcached client has somewhat of a startup cost and it
> has a connection pool, so it works best if the database only keeps one CLR
> for all triggers.
>
> /Henrik
>
>
>
> On Fri, Oct 2, 2009 at 12:00, Adi <adeelna...@gmail.com> wrote:
>
> > All,
> > I am using memcached on windows server 2003 and using Be.IT memcached
> > client.
>
> > How can i remove cache object when any direct database change occur, i
> > want to invalidate / remove cache objects from memcached server, for
> > this i am thinking about the CLR stored procedure.
>
> > What if i write a trigger that activate on Update/Delete evetns and
> > call the CLR stored procedure to remove cache objects? somebody tried
> > this thing before?
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -
Dan Wierenga
Re: CLR Stored Procedure for Remove cache objects
October 02, 2009 08:30PM
> -----Original Message-----
> From: memcached@googlegroups.com [mailto:[email protected]]
>On Behalf Of Adi
> Sent: Friday, October 02, 2009 6:00 AM
> To: memcached
> Subject: Re: CLR Stored Procedure for Remove cache objects
>
>
> I got your point, i don't want to cache the table rows. please explain
> "object relational mapper"?

Microsoft's version of "object relational mapper" is LINQ (Language
INtegrated Query). That's where you'd want your app to talk to the cache,
not from a CLR procedure.
Kevin Amerson
Re: CLR Stored Procedure for Remove cache objects
October 02, 2009 08:40PM
You can also go with NHibernate and use NHibernate.Linq along with the
NHibernate's memcached client that basically hooks in through configuration
settings.

On Fri, Oct 2, 2009 at 11:59 AM, Dan Wierenga <[email protected]> wrote:

> > -----Original Message-----
> > From: memcached@googlegroups.com [mailto:[email protected]]
> >On Behalf Of Adi
> > Sent: Friday, October 02, 2009 6:00 AM
> > To: memcached
> > Subject: Re: CLR Stored Procedure for Remove cache objects
> >
> >
> > I got your point, i don't want to cache the table rows. please explain
> > "object relational mapper"?
>
> Microsoft's version of "object relational mapper" is LINQ (Language
> INtegrated Query). That's where you'd want your app to talk to the cache,
> not from a CLR procedure.
>
>
>
>
>
>
Sorry, only registered users may post in this forum.

Click here to login