C
Chris
Hi All,
I've recently been making use of data caching by storing small,
frequently accessed, infrequently updated tables in the cache.
I've been using a static class to maintain access to cached data:
public static Meeting getMeeting(string _idMeeting)
{
if (checkMeetingCached(_idMeeting))
{
return getMeetingFromCache(_idMeeting);
}
else
{
lock (Meetings)
{//to make sure 2 users are not adding the same data
to the cache, we'll do one more check
//on the cache.
if (checkMeetingCached(_idMeeting))
{
return getMeetingFromCache(_idMeeting);
}
else
{
return addMeetingToCache(_idMeeting);
}
}
}
}
What this does is simply check if the meeting is in the cache, if not,
it adds it and accesses it from the cache with future requests.
Is my use of static class appropriate? Or would this be causing any
form of performance issue? Meetings are stored in a DataTable called
"Meetings".
If the cache["tablename"] is null, the meeting table is created and
inserted into that cache var. If not null, it is assigned to a
datatable object for the duration of the request.
I have been given a project which utilises a MySQL db. The main table
it references has 8000 records. These records are searchable. The site
has a bespoke paging mechanism for search results. So each query will
first hit the db to find a COUNT() matched records, then another DB
hit to return a set number of records, and a final db hit to retrieve
the selected information.
Would I see any performance increase by caching the entire table of
8000 records? It would remove all DB hits apart from the one which
inserts the table to cache, but i'm unsure if this would outweigh
other performance penalties.
Any help and advice is appreciated,
Chris
I've recently been making use of data caching by storing small,
frequently accessed, infrequently updated tables in the cache.
I've been using a static class to maintain access to cached data:
public static Meeting getMeeting(string _idMeeting)
{
if (checkMeetingCached(_idMeeting))
{
return getMeetingFromCache(_idMeeting);
}
else
{
lock (Meetings)
{//to make sure 2 users are not adding the same data
to the cache, we'll do one more check
//on the cache.
if (checkMeetingCached(_idMeeting))
{
return getMeetingFromCache(_idMeeting);
}
else
{
return addMeetingToCache(_idMeeting);
}
}
}
}
What this does is simply check if the meeting is in the cache, if not,
it adds it and accesses it from the cache with future requests.
Is my use of static class appropriate? Or would this be causing any
form of performance issue? Meetings are stored in a DataTable called
"Meetings".
If the cache["tablename"] is null, the meeting table is created and
inserted into that cache var. If not null, it is assigned to a
datatable object for the duration of the request.
I have been given a project which utilises a MySQL db. The main table
it references has 8000 records. These records are searchable. The site
has a bespoke paging mechanism for search results. So each query will
first hit the db to find a COUNT() matched records, then another DB
hit to return a set number of records, and a final db hit to retrieve
the selected information.
Would I see any performance increase by caching the entire table of
8000 records? It would remove all DB hits apart from the one which
inserts the table to cache, but i'm unsure if this would outweigh
other performance penalties.
Any help and advice is appreciated,
Chris