Adds an RRset to the Cache. @param rrset The RRset to be added @param cred The credibility of these records @see RRset
(RRset rrset, int cred)
| 348 | * @see RRset |
| 349 | */ |
| 350 | public synchronized void |
| 351 | addRRset(RRset rrset, int cred) { |
| 352 | long ttl = rrset.getTTL(); |
| 353 | Name name = rrset.getName(); |
| 354 | int type = rrset.getType(); |
| 355 | Element element = findElement(name, type, 0); |
| 356 | if (ttl == 0) { |
| 357 | if (element != null && element.compareCredibility(cred) <= 0) |
| 358 | removeElement(name, type); |
| 359 | } else { |
| 360 | if (element != null && element.compareCredibility(cred) <= 0) |
| 361 | element = null; |
| 362 | if (element == null) { |
| 363 | CacheRRset crrset; |
| 364 | if (rrset instanceof CacheRRset) |
| 365 | crrset = (CacheRRset) rrset; |
| 366 | else |
| 367 | crrset = new CacheRRset(rrset, cred, maxcache); |
| 368 | addElement(name, crrset); |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Adds a negative entry to the Cache. |
no test coverage detected