#include <XrdNetCache.hh>
|
static void | SetKT (int ktval) |
Definition at line 41 of file XrdNetCache.hh.
◆ XrdNetCache::anItem.__unnamed0__
union XrdNetCache::anItem.__unnamed0__ |
Definition at line 96 of file XrdNetCache.hh.
Class Members |
int |
aV4[4] |
|
long long |
aV6[2] |
|
char |
aVal[16] |
|
◆ XrdNetCache()
XrdNetCache::XrdNetCache |
( |
int | psize = 987, |
|
|
int | csize = 1597 ) |
Constructor. When allocateing a new hash, two adjacent Fibonocci numbers. The series is simply n[j] = n[j-1] + n[j-2].
- Parameters
-
psize | the correct Fibonocci antecedent to csize. |
csize | the initial size of the table. |
Definition at line 49 of file XrdNetCache.cc.
50{
51 prevtablesize = psize;
52 nashtablesize = csize;
53 Threshold = (csize * LoadMax) / 100;
54 nashnum = 0;
55 nashtable = (anItem **)malloc( (size_t)(csize*sizeof(anItem *)) );
56 memset((void *)nashtable, 0, (size_t)(csize*sizeof(anItem *)));
57}
◆ ~XrdNetCache()
XrdNetCache::~XrdNetCache |
( |
| ) |
|
|
inline |
Destructor. The XrdNetCache object is not designed to be deleted. Doing so will cause memory to be lost.
Definition at line 89 of file XrdNetCache.hh.
◆ Add()
Add an address-hostname association to the cache. The address must be an INET family address; otherwise it is not added.
- Parameters
-
hAddr | points to the address of the name. |
hName | points to the name to be associated with the address. |
Definition at line 63 of file XrdNetCache.cc.
64{
65 anItem Item, *hip;
66 int kent;
67
68
69
70 if (!GenKey(Item, hAddr)) return;
71
72
73
74 myMutex.Lock();
75 if ((hip = Locate(Item)))
76 {if (hip->hName) free(hip->hName);
77 hip->hName = strdup(hName);
78 hip->expTime = time(0) + keepTime;
79 myMutex.UnLock();
80 return;
81 }
82
83
84
85 if (++nashnum > Threshold) Expand();
86
87
88
89 hip = new anItem(Item, hName, keepTime);
90
91
92
93 kent = hip->aHash % nashtablesize;
94 hip->Next = nashtable[kent];
95 nashtable[kent] = hip;
96 myMutex.UnLock();
97}
◆ Find()
Locate an address-hostname association in the cache.
- Parameters
-
hAddr | points to the address of the name. |
- Returns
- Success: an strdup'd string of the corresponding name. Failure: 0;
Definition at line 148 of file XrdNetCache.cc.
149{
150 anItem Item, *nip, *pip = 0;
151 int kent;
152
153
154
155 if (!GenKey(Item, hAddr)) return 0;
156
157
158
159 myMutex.Lock();
160 kent = Item.aHash%nashtablesize;
161
162
163
164 nip = nashtable[kent];
165 while(nip && *nip != Item) {pip = nip; nip = nip->Next;}
166 if (!nip) {myMutex.UnLock(); return 0;}
167
168
169
170 if (nip->expTime > time(0))
171 {char *hName = strdup(nip->hName);
172 myMutex.UnLock();
173 return hName;
174 }
175
176
177
178 if (pip) pip->Next = nip->Next;
179 else nashtable[kent] = nip->Next;
180 myMutex.UnLock();
181 delete nip;
182 return 0;
183}
◆ SetKT()
void XrdNetCache::SetKT |
( |
int | ktval | ) |
|
|
inlinestatic |
Set the default keep time for entries in the cache during initialization.
- Parameters
-
ktval | the number of seconds to keep an entry in the cache. |
Definition at line 72 of file XrdNetCache.hh.
The documentation for this class was generated from the following files: