[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

Learning simple cache implementations

Paul

5/1/2016 1:08:00 PM

I have an ok background in Algorithms and Data Structures (for example CLRS) but am stumped when applying this to architecture or design problems.

The below problem stumps me. The URL is given and the text is also pasted. Any advice on what to read/study so that I can tackle questions which have a similar flavour? I would prefer free resources if possible.

Many thanks for your help.

Paul


https://www.careercup.com/question?id=571907...
You are given an scenario where there is an Worker object. Each Worker object has one mandatory field unique id workerId and their are few other non unique and not mandatory Ids : DeptId and UnitID.
Design an cache for your Worker objects considering the fact that most of the queries on your cache will be on unitId. If the there is an query for an Worker which is not available in your cache then that data will be fetched from the server.
Design an cache such that there will be minimum number of server calls. Imagine there are 100;s of such non unique ids non mandatory Ids in the Worker object and you have to design the cache so that your client can query on any given id with minimum calls to server.

Your Worker object looks like this:
Worker1=> workerid=1, deptId=>765, unitId=>123 Name="" Surname="" Data=""
Worker2=> workerid=2 , deptId=>765 Name="" Surname="" Data=""
Worker3=> workerid=3, unitid=>123 Name="" Surname="" Data=""

so when your client queries using unitId getWorkersbyUnitId(123) it should return Worker1 and Worker3.
If query is on deptId 765 then it should return Worker1 and Worker2

You can assume there is never an query on individual workerId.

other information given while discussion is you can query the server using any id and all the worker objects of that id will be fetched by that single call: Example there are 10 workers associated with untId: 99 then server call to getserverUnitIdWorkers(99)-> will output list of 10 workers. Each unitId or any other non mandatory id has approximate 8 to 10 workers associated with it. And there are millions of such unitIds.

3 Answers

SilentOtto

9/4/2008 5:19:00 AM

0

On Sep 3, 11:30 pm, Governor Swill <governor.sw...@gmail.com> wrote:
> This is SilentOtto's brain on drugs:
>
>
>
> >> We heard that in '72.  McGovern was going to win in a landslide with
> >> the antiwar and youth vote.  Didn't happen.
>
> >That's true, but the dynamic seems to be different this time around.
>
> >The youth vote have increased their turn out over both of the last two
> >presidental election cycles.  It was up 11% in 2004 over 2000.
>
> >There are also record numbers of young people registering to vote,
> >mostly as democrats, and the Democrat primaries saw record turn out.
>
> >That, coupled with the fact that Obama is getting the majority of his
> >money from small individual donors, and young people are well
> >represented among those donors, suggest that this time around young
> >voters may actually turn out.
>
> >People who take the time to register, donate money and vote in
> >primaries are almost certain to vote in the general election.
>
> I'm not counting on it.  The voters' memories can be very short.
> They've already forgotten how angry they were about Iraq a year ago,
> how incensed about the economy six months ago and what happened to gas
> prices just weeks ago.

Well... I suppose I'm not -counting on it- either. But, it would be
a welcome development and would turn a clear win into a landslide.

>
> Swill
> --
> It's a good thing Palin's a member of the NRA
> 'cause she's got a shotgun wedding coming up.
> Picture ofthe day:http://apod.nasa...

SilentOtto

9/4/2008 5:50:00 AM

0

On Sep 3, 11:45 pm, Governor Swill <governor.sw...@gmail.com> wrote:
> This is SilentOtto's brain on drugs:
>
> >> Saddam took Iraq off the petrodollar.  That couldn't be tolerated and
> >> explains much about how our support split in Europe.  Germany and
> >> France have lots of euros.  The Spanish and Italians not so much.  The
> >> Brits don't use them but the Irish do.
>
> >Agreed.
>
> >Then there was the pay back when the Bush administration started
> >awarding contracts for rebuilding Iraq, and how they publicly declared
> >that they were going to freeze out most of Europe.

Three different replies to one post?

Well... I suppose you've your reasons.

> The Saudis are our BFFs.  Yet somehow, they've ended up having to
> watch Iranian power grow in the region.  Either Iran's resurgence onto
> the world stage is a shocking and humiliating series of unintended
> consequences of the Iraq War or the neocons and Cheney have
> constructed an elaborate charade against the Saudis and within the
> Muslim world.  After all, what better way to divide Moslems than to
> pretend to help the majority while actually boosting the underdog?

I don't think the NeoCons are that clever. They've been following a
pretty straight forward big stick sort of foreign policy and only
deviate from it when they absolutely have to.

I think they really believed their rhetoric about the ease of removing
Saddam and being greeted as liberators.

Once Saddam was gone and Iraq a stable democracy filled with permanent
U.S. bases to Iran's east, with a similar situation in the west in
Afghanistan and with a NATO state to the north in Georgia and U.S.
friendly states to their northeast in Turkmenistan and Uzbekistan,
Iran would be surrounded by U.S. military force. That would give the
reformers in Iran the confidence they needed to take on the hard
liners, with U.S. backing and support, and win.

Russia, which has been similarly surrounded, engages in a lot of
bluster, but is basically impotent in the face of the U.S. strategic
advantage.

Democracy breaks out all over the Middle East and it's happy-happy-joy-
joy into the golden sunrise of U.S. style corporate capitalism under
U.S. global hegemony.

Republicans are hailed as heroes by the American people and they
secure their permanent hold on the U.S. government.

George W. Bush's head is carved into Mt. Rushmore.







Öö Tiib

5/1/2016 3:07:00 PM

0

On Sunday, 1 May 2016 16:07:47 UTC+3, Paul wrote:
> I have an ok background in Algorithms and Data Structures (for example CLRS) but am stumped when applying this to architecture or design problems.
>
> The below problem stumps me. The URL is given and the text is also
> pasted. Any advice on what to read/study so that I can tackle
> questions which have a similar flavour? I would prefer free resources
> if possible.
>
> Many thanks for your help.
>
> Paul
>
>
> https://www.careercup.com/question?id=571907...

That problem has more generic solution in every database engine there is
because all of those have data and index caching. It is just way simpler
because it has one concrete record and two concrete indexes to it
(nothing generic) and also no server-side changes/updates to cache
are required.

We do not know what part of it exactly stumps you. Please be more
specific.