1

00:00:01,080  -->  00:00:02,240
Hi there.

2

00:00:02,460  -->  00:00:09,170
Now let's look at Lincoln National if you recall when Scott has said unladen link has said.

3

00:00:09,340  -->  00:00:16,140
He said that Hastert does not preserve social order but Lynch has said extensor has set up reserves

4

00:00:16,200  -->  00:00:22,880
in such an order and is also almost as fast as a hassle just because it extends Hassen.

5

00:00:23,340  -->  00:00:29,700
Similarly the map implementation's hash map does not because of insertion order one linked hash map

6

00:00:29,910  -->  00:00:35,890
which extends the hash map does so in such an order that not much difference in this speed.

7

00:00:36,390  -->  00:00:39,130
So the set up is exactly at anything.

8

00:00:39,230  -->  00:00:40,450
Implementations.

9

00:00:40,530  -->  00:00:43,100
We have the has set on that subclass.

10

00:00:43,100  -->  00:00:46,170
Link has set Verizon map implementations.

11

00:00:46,200  -->  00:00:53,250
We have hashed map undersupply us and encashment and we know that internally has set uses a hash map

12

00:00:53,390  -->  00:00:57,960
on link has set uses it linked Hashanah.

13

00:00:57,960  -->  00:01:02,960
So he had other key points of her linked hash map on most of this stuff is reported to from earlier

14

00:01:02,970  -->  00:01:05,170
lessons on Henson's very straightforward.

15

00:01:05,360  -->  00:01:12,390
But let's quickly glance to them linked to hash map is basically a hash table as well as a linked list

16

00:01:12,420  -->  00:01:19,560
implementation of a map because it has a doubly linked list running through its entries which help in

17

00:01:19,590  -->  00:01:23,050
preserving the order off in certain mappings.

18

00:01:23,070  -->  00:01:29,610
But it extends the hash not Osoyoos almost as fast as a hash small and slight Malonis will be due to

19

00:01:29,610  -->  00:01:33,010
the expense of maintaining a linked list.

20

00:01:33,030  -->  00:01:40,590
So just like hash map lookup insertion and deletion operations are somewhat constant I also like a hash

21

00:01:40,590  -->  00:01:45,880
map linked hash map where it's not allowed use and also exactly one NULL.

22

00:01:46,470  -->  00:01:53,730
So if there is already a mapping within Alte try to add a new mapping with a null key once again then

23

00:01:53,730  -->  00:01:56,400
the value in the old mapping will be replaceable.

24

00:01:56,410  -->  00:02:01,000
The new I look in the new moppy and we already know that.

25

00:02:01,860  -->  00:02:08,040
Finally it's methods are not synchronized just like in the case of the hash mob under synchronization

26

00:02:08,040  -->  00:02:08,840
is required.

27

00:02:08,910  -->  00:02:14,170
It can always be they can get off externally as we will see later when we get to the Mugby trading partner

28

00:02:14,200  -->  00:02:15,410
.

29

00:02:16,270  -->  00:02:18,130
And this is about activation speed.

30

00:02:18,220  -->  00:02:24,120
And this was also discussed in length has surplus and since Lynch has said in an early is of selling

31

00:02:24,120  -->  00:02:30,630
Hasham up there is absolutely nothing which is different from what we discussed earlier in encashment

32

00:02:30,630  -->  00:02:34,650
only slightly faster than hashmarks when it comes to iterating them out.

33

00:02:34,780  -->  00:02:41,010
And that's because it duration length hash map is dependent on the size of the map due to the use of

34

00:02:41,130  -->  00:02:42,650
doubly linked list.

35

00:02:42,860  -->  00:02:48,600
There doesn't the kings of hash map the duration is dependent on the capacity right which could be much

36

00:02:48,600  -->  00:02:52,410
greater than the actual size of the map.

37

00:02:52,680  -->  00:02:55,920
And here comes a very interesting feature offering hash.

38

00:02:56,330  -->  00:03:04,990
It can be used as an LRU cache where you transport least use and be used if you're not sure what a cache

39

00:03:04,990  -->  00:03:05,770
means.

40

00:03:05,790  -->  00:03:11,670
It is basically a component that stores important and data so that this important data can be quickly

41

00:03:11,670  -->  00:03:12,950
access.

42

00:03:13,020  -->  00:03:18,710
Now when you say important it could mean anything depending on the application in context.

43

00:03:19,250  -->  00:03:26,820
It could signify most recently used items or most frequently access items are in a Facebook like application

44

00:03:26,890  -->  00:03:34,380
it could mean most liked or most shared items all of the heavily trafficked Web sites cache lots and

45

00:03:34,380  -->  00:03:40,720
lots of data so that the response time in written Ingur pages will be very fast.

46

00:03:40,920  -->  00:03:46,360
You just cannot always access the database cross-stitching your most important data.

47

00:03:47,010  -->  00:03:54,090
Memcached is a very popular in-memory gushing system that you cough up so sites made news on a note

48

00:03:54,090  -->  00:04:02,400
that such data is stored in RAM fast boxes and these websites use lots and lots of room so they don't

49

00:04:02,400  -->  00:04:09,120
use the database for fetching the data on every single Axel's lot of data will be stored in the cache

50

00:04:09,180  -->  00:04:15,960
Engram and that is more bit hard to use since in encashment can be used as a lot of cash.

51

00:04:15,990  -->  00:04:17,290
Let's look at an illustration.

52

00:04:17,320  -->  00:04:25,210
Also allow you cash and a lot in cash uses least recently used caching strategy.

53

00:04:25,350  -->  00:04:31,440
There can be many strategies but this is the strategy that an alarm Lukash uses on running of the cash

54

00:04:31,440  -->  00:04:31,530
.

55

00:04:31,560  -->  00:04:35,130
We have the least recently used item while on the other.

56

00:04:35,160  -->  00:04:42,000
We have the most recently used item so items on order according to how recently they were used.

57

00:04:43,260  -->  00:04:49,100
Honestly are done in green with cash that would be considered as the most recently used item will be

58

00:04:49,100  -->  00:04:54,010
added on the air and has been most recently used item.

59

00:04:54,030  -->  00:05:00,200
Now if the cash is full then the new entry will be added under the least recently added entry.

60

00:05:00,240  -->  00:05:02,680
On the other and we're getting more.

61

00:05:03,030  -->  00:05:12,060
Sometimes the victim and victim is for the more cash typically has a sexes no other than in session

62

00:05:12,060  -->  00:05:12,340
.

63

00:05:12,390  -->  00:05:18,000
If an entry in the cash is accessed then that entry there'll be more prudent and which present.

64

00:05:18,030  -->  00:05:21,260
Most recently Axel's writing due to this.

65

00:05:21,270  -->  00:05:26,240
Any items that come before that access item are shared by one position.

66

00:05:26,730  -->  00:05:31,230
Note that in this case there is no elementary middle as we are only Mogen the elements.

67

00:05:31,230  -->  00:05:37,840
I don't know that if you are searching for an item and that item is found in the cache then the seductive

68

00:05:38,270  -->  00:05:39,480
cashier.

69

00:05:40,200  -->  00:05:45,600
But if the item is not found in the cash then we say that you have a cache miss and we try to find the

70

00:05:45,600  -->  00:05:48,530
item in the database on the phone.

71

00:05:48,660  -->  00:05:51,210
Well the Mogen got cash.

72

00:05:51,400  -->  00:05:56,000
Of know that this LRU cache is a feature of only link Hashima.

73

00:05:56,220  -->  00:06:01,510
It does not act like a link has set although link has it in only use ascending hash.

74

00:06:02,040  -->  00:06:07,050
No let me pull up the linked hash maps API and we can look at the constructs that would allow us to

75

00:06:07,050  -->  00:06:10,360
use link hash map as an alarming cache.

76

00:06:10,440  -->  00:06:15,780
After that we would also agree on am offline hash map and we'll see how it can be used as an LRU cache

77

00:06:15,790  -->  00:06:18,330
.

78

00:06:18,330  -->  00:06:19,310
OK here's a link.

79

00:06:19,310  -->  00:06:27,520
Hash map class and we are in the Java 8 API so we are looking at July 8 and as we can see here this

80

00:06:27,540  -->  00:06:29,250
is the definition.

81

00:06:29,250  -->  00:06:31,750
So the linked hash map extrinsic Hashima.

82

00:06:32,100  -->  00:06:39,330
So it is a national honor to implement the map and you can also check out the description of the specification

83

00:06:39,850  -->  00:06:42,570
and we have already discussed most often in our lesson.

84

00:06:42,840  -->  00:06:46,850
But if you want to you can still look at it.

85

00:06:47,670  -->  00:06:51,350
So here are the different construct Girsh are aren't we are concerned about.

86

00:06:51,360  -->  00:06:56,190
On the one constructor with regards to the LRU cache and that is just one.

87

00:06:56,360  -->  00:07:00,900
OK so this particular constructor it takes three parameters one has the capacity.

88

00:07:00,900  -->  00:07:06,560
Another is a low Kacher because it's a map and the third one is Axel's order.

89

00:07:06,810  -->  00:07:14,870
OK now if you pass a false to this constructor then NENKE hash mob will not act as a LRU cache.

90

00:07:15,300  -->  00:07:21,620
But if you pass through court access order then it would be horizon and argue cash.

91

00:07:21,660  -->  00:07:28,740
However the LRU cache size would be unlimited which means that the elements on one end which are least

92

00:07:28,740  -->  00:07:31,010
recently used will not be removed.

93

00:07:31,050  -->  00:07:37,410
OK that particular element will not be read more than the insert a new element in dialog Googoosh.

94

00:07:37,470  -->  00:07:43,890
Now if you want to really Moeder element on if you want to have a fixed size call that a lot of us which

95

00:07:43,890  -->  00:07:49,280
is normally done is then what you need to do is you need to subclass discuss.

96

00:07:49,440  -->  00:07:53,330
OK so you need to extend this glassing to create a new class with text.

97

00:07:53,400  -->  00:08:00,480
Until you can see why the size of LRU cache not in order to remove the least recently used item.

98

00:08:00,480  -->  00:08:07,170
There is this matter called as a remote a list entry search sisig remote and yesterday which means that

99

00:08:07,170  -->  00:08:15,000
we are removing the entry under Andrius nothing back the entry which is least recently used now when

100

00:08:15,000  -->  00:08:21,910
we insert an item using the method or called motard got called in will this particular method.

101

00:08:21,990  -->  00:08:27,230
In fact in this particular blast this method will always get done a false pretenses false.

102

00:08:27,240  -->  00:08:29,950
It means that a list entry should not be removed.

103

00:08:30,330  -->  00:08:33,910
So by default this linked hash mobbers not mode.

104

00:08:34,660  -->  00:08:38,550
But we want that lost or injured will be removed if the cache is full.

105

00:08:38,550  -->  00:08:45,240
OK so Hadari create a subclass unbe override this matter on that subplot and the subclass will define

106

00:08:45,570  -->  00:08:53,580
a purse size for the cache and when the sizes full trying to insert an item then the most and B should

107

00:08:53,580  -->  00:08:54,700
be removed.

108

00:08:54,810  -->  00:09:02,100
So this method will be invoked by both as well as all mockups because those are the insertion of on

109

00:09:02,100  -->  00:09:04,010
every time we insert and add a minute.

110

00:09:04,020  -->  00:09:10,590
This method would be in-work and that lesson will also be passed on but within this entry we can this

111

00:09:10,590  -->  00:09:11,740
matter.

112

00:09:11,730  -->  00:09:14,760
We will actually see if the sizes.

113

00:09:15,210  -->  00:09:18,190
If the class sizes can then be written.

114

00:09:18,510  -->  00:09:23,060
In which case Dismuke this particular entry will be removed by the class.

115

00:09:23,200  -->  00:09:28,970
OK so it would be removed and the option now of the size is not your fault.

116

00:09:28,980  -->  00:09:32,460
That will work enough flaws aren't annoying and may be removed.

117

00:09:33,030  -->  00:09:36,470
So this particular parameter will not do anything with the parameter.

118

00:09:36,510  -->  00:09:40,830
Typically it is just passed but getting this method will be all right.

119

00:09:40,830  -->  00:09:45,000
We typically look at the size on Meryton either true or false.

120

00:09:45,210  -->  00:09:48,540
Ok we'll sizing is reached max sizes reach the middle and accrue.

121

00:09:48,540  -->  00:09:53,750
Otherwise we don't know who was on when that the hash map the put method which says order put on my

122

00:09:53,760  -->  00:10:01,130
third most popular and just in case you want to reward me in this matter then you should ensure that

123

00:10:01,120  -->  00:10:06,980
you all get it or don't have flaws was so that put off but put all motard will not bring it on there

124

00:10:07,110  -->  00:10:07,620
.

125

00:10:08,240  -->  00:10:13,730
So that's about getting more or less in theory but let's go hard on much to blur them on striation and

126

00:10:13,750  -->  00:10:18,370
we will actually look at we'll create a subclass and we will actually override this.

127

00:10:18,380  -->  00:10:21,740
So let's head over to our editor or not.

128

00:10:23,070  -->  00:10:23,300
OK.

129

00:10:23,330  -->  00:10:29,310
Here we are in the map Demopolis on a new Materne called LRU cache dust has been added.

130

00:10:29,520  -->  00:10:32,620
Ok so here the code has already been written.

131

00:10:32,840  -->  00:10:38,410
So we are going to create a little hash map and initially we are not going to use it as an add on you

132

00:10:38,410  -->  00:10:38,930
cache.

133

00:10:39,070  -->  00:10:39,280
OK.

134

00:10:39,280  -->  00:10:41,600
So this is a constructor which we have seen already.

135

00:10:41,810  -->  00:10:45,710
So we are going to pass a false on we are going in search through mappings.

136

00:10:45,750  -->  00:10:52,710
We're going to print it a little PP-ASEL true value and then we will see how it works Asom LRU cache

137

00:10:52,720  -->  00:10:53,040
.

138

00:10:53,290  -->  00:10:58,750
And we also said that we can subclass it so that we can set the size of the new cash and we'll also

139

00:10:58,750  -->  00:10:59,430
look at that.

140

00:10:59,530  -->  00:11:02,290
So there are three things that we are going to test.

141

00:11:02,420  -->  00:11:08,770
So we are going to pass a force which means that the hash map the hash map is not going to be as on

142

00:11:08,840  -->  00:11:10,480
allow you cache it.

143

00:11:10,580  -->  00:11:14,000
So here you are inserting three strings three mappings.

144

00:11:14,020  -->  00:11:18,560
So it is a map or a string or a string so the string value is string.

145

00:11:18,620  -->  00:11:23,990
And here you are in doing it in small gains on the value is a number is.

146

00:11:24,050  -->  00:11:33,050
So you're writing in here BBC and we are spending it and we are next Shingo value for you and we are

147

00:11:33,050  -->  00:11:37,460
doing it price and we're going to go in printing the value of the dollar you cash.

148

00:11:37,760  -->  00:11:41,920
And that would make sense on me as if I had access on a lot of cash.

149

00:11:41,990  -->  00:11:43,400
So it will not.

150

00:11:43,490  -->  00:11:46,140
It doesn't make sense for this demonstration.

151

00:11:46,220  -->  00:11:54,700
We are watching the value beat the value for the ECB and we are printing it and we are adding a couple

152

00:11:54,710  -->  00:11:55,570
of more mappings.

153

00:11:55,580  -->  00:11:59,730
DD And then each action we print and go on here.

154

00:11:59,840  -->  00:12:05,730
So let me just go to aren't those here or does it just.

155

00:12:06,800  -->  00:12:08,640
So here is the first one.

156

00:12:08,750  -->  00:12:16,580
Some people think is OK maybe the NCC and after fetching the value the value for the key we are printing

157

00:12:16,580  -->  00:12:22,450
it once again and once again it's just the same mapping the same old book and after fetching the value

158

00:12:22,450  -->  00:12:25,590
forby of on second printing on second the same thing.

159

00:12:25,610  -->  00:12:29,980
And then we're adding B and then printing the cash on them there aren't any.

160

00:12:30,060  -->  00:12:31,050
Nobody in the cash.

161

00:12:31,070  -->  00:12:33,670
So this is like a regular map.

162

00:12:33,760  -->  00:12:35,410
It's just a hash map.

163

00:12:35,480  -->  00:12:37,460
So you want to change continue to hashmarks.

164

00:12:37,570  -->  00:12:39,550
You will be able to see any difference.

165

00:12:39,620  -->  00:12:43,170
It's just not internally a hash map is used as its own implementation.

166

00:12:43,170  -->  00:12:46,420
It doesn't hash not users and then list also.

167

00:12:46,420  -->  00:12:47,650
Now let's go on.

168

00:12:47,720  -->  00:12:50,170
Esther Esther doesn't lot gosh.

169

00:12:50,210  -->  00:12:54,180
So we just passed through.

170

00:12:54,220  -->  00:12:54,870
Here it is.

171

00:12:54,880  -->  00:12:58,140
So the hustle of the household put this to love him.

172

00:12:58,250  -->  00:13:03,210
And here we are that you know value for lucky.

173

00:13:03,350  -->  00:13:06,960
Now it is the value the mapping is being accessed.

174

00:13:07,000  -->  00:13:13,280
So the mapping that has is the most recently used on as you can see the Kukla corresponding mapping

175

00:13:13,460  -->  00:13:20,780
has been more the Google and which represents the most recently used most recent news item.

176

00:13:21,050  -->  00:13:23,600
So how BBC see on it.

177

00:13:23,880  -->  00:13:30,470
Now the thing is this having multiple calls who will not make any difference.

178

00:13:30,980  -->  00:13:36,560
So it doesn't make any difference whether you Axel's the value price or even once.

179

00:13:36,830  -->  00:13:40,980
I and here we are getting more value for be on the TV.

180

00:13:41,000  -->  00:13:43,810
So the mapping with B is more than a friend.

181

00:13:43,970  -->  00:13:49,100
OK so that's what this particular instrument is showing us the market.

182

00:13:49,460  -->  00:13:51,240
Next we are inserting B.

183

00:13:51,250  -->  00:13:57,640
So D would be the most recently used item so be added here.

184

00:13:58,010  -->  00:14:00,060
And is added here later.

185

00:14:00,250  -->  00:14:03,370
So there is no elementary mall shopping at the mall here.

186

00:14:03,520  -->  00:14:07,950
As we discussed earlier and the size of the BOP is also on every day.

187

00:14:08,000  -->  00:14:15,120
So you can go had an are more and more mappings and they just decided to go up.

188

00:14:15,450  -->  00:14:20,050
Now do the final one which is an alarm cashbook a fixed size.

189

00:14:20,330  -->  00:14:21,200
Dock.

190

00:14:22,370  -->  00:14:30,050
There is a new glass here along Lukash and as discussed earlier Extreme's the lens has Sh'ma.

191

00:14:30,500  -->  00:14:38,830
It is all what writing this motard card the more and less and and this glass also defines what size

192

00:14:39,050  -->  00:14:40,910
the max and he's history.

193

00:14:41,000  -->  00:14:46,030
You can use the cash and how only three elements add the max.

194

00:14:46,180  -->  00:14:53,240
And we are also the alarm your cash so we will basically instantiate this particular class and we will

195

00:14:53,240  -->  00:14:54,340
pass these values.

196

00:14:54,350  -->  00:15:00,590
And this is in done in Wolken the concept in the superclass is and then hash map and link hash map.

197

00:15:00,620  -->  00:15:02,220
Then we try to insert an element.

198

00:15:02,240  -->  00:15:07,060
It will involve this be more or less and treat it as passing the element that needs to be read more

199

00:15:07,080  -->  00:15:07,300
.

200

00:15:07,510  -->  00:15:12,400
But like I mentioned earlier we are not going to do anything with this particular parameter.

201

00:15:12,480  -->  00:15:16,340
Are we just you don't recall our falls half the size.

202

00:15:16,340  -->  00:15:23,650
Here we are in the seismometer and them in dealing hash map class and if the size is greater than max

203

00:15:23,720  -->  00:15:31,550
increase which means the cache is full and history in which case it would return at three and record

204

00:15:31,630  -->  00:15:37,100
it couldn't looks a good return crew on and that is to put my third order book on the motor when somebody

205

00:15:37,120  -->  00:15:38,370
Mode-S enemy.

206

00:15:38,780  -->  00:15:41,660
Now if the size is not dead then this will be false.

207

00:15:41,650  -->  00:15:43,960
Which means or the size is less than max increase.

208

00:15:44,000  -->  00:15:48,110
So the the cache sizes not yet is not the call.

209

00:15:48,430  -->  00:15:53,180
In which case it claws will be repaired and that entry will not be removed.

210

00:15:53,250  -->  00:15:56,330
So understandability more only when the sizes.

211

00:15:56,570  -->  00:16:04,770
So let's go ahead and just change this this and we are still passing crews so we're good.

212

00:16:04,820  -->  00:16:06,530
So Tzschirner once again.

213

00:16:06,600  -->  00:16:08,890
And as you can see the sizes are listed.

214

00:16:09,110  -->  00:16:17,190
So initially it bends all of the elements then we are accessing a Kreiss but it doesn't make any difference

215

00:16:17,180  -->  00:16:17,200
.

216

00:16:17,200  -->  00:16:18,770
Only once is good enough.

217

00:16:18,980  -->  00:16:25,340
So it to move here but just at the moment axis we're not on any at the moment.

218

00:16:25,340  -->  00:16:31,790
So we still have both B and C sources and then more than just get by one position then is axles so B

219

00:16:31,790  -->  00:16:36,580
will come on the front and it will be moved here to slack on Sistan day.

220

00:16:36,800  -->  00:16:42,720
Then we are inserting the new mapping the insert will be added here.

221

00:16:43,070  -->  00:16:46,450
And the least recently used mapping is Sea.

222

00:16:46,490  -->  00:16:47,930
So that gets to the third.

223

00:16:48,130  -->  00:16:54,320
So that particular matter gets in would be more or less the entry on the nation and receive Samal NCM

224

00:16:54,320  -->  00:16:56,220
happens when we insert it.

225

00:16:56,440  -->  00:16:59,960
He's here Bismo here and these more here.

226

00:17:00,140  -->  00:17:02,970
The last entry is tomorrow.

227

00:17:03,350  -->  00:17:05,950
So that's all there is.

228

00:17:06,010  -->  00:17:12,260
So it's a wonderful data structure on the circle all you have to use a caching mechanism that will allow

229

00:17:12,260  -->  00:17:15,210
you mentioned strategy then you can make use of this class.

230

00:17:15,470  -->  00:17:19,070
But when you're developing like large search you would typically use memcache.

231

00:17:19,240  -->  00:17:21,310
But still there can be chances.

232

00:17:21,320  -->  00:17:21,850
Got you.

233

00:17:21,850  -->  00:17:28,130
Mr. Inhofe you may want to use this in certain situations where you want to use something like memcached

234

00:17:28,120  -->  00:17:28,280
.

235

00:17:28,370  -->  00:17:32,690
So there might be some components that you are developing on thought that maybe this will do a good

236

00:17:32,680  -->  00:17:34,000
job for you.

237

00:17:34,120  -->  00:17:39,360
So that's about Hashima and what code is available in the resource section.

238

00:17:39,510  -->  00:17:40,180
Thank you.

239

00:17:40,220  -->  00:17:41,350
I'm happy coding
