1: package body WF_OBJECT_CACHE as
2: /* $Header: WFOBCACB.pls 120.0.12010000.2 2008/08/09 13:36:23 sstomar ship $ */
3:
4: /*-------------------+
5: | Caching strutures |
53: g_Object_List(p_cache_index).Overflow := false;
54:
55: exception
56: when others then
57: wf_core.context('WF_OBJECT_CACHE', 'CreateCache', p_cache_index);
58: raise;
59: end CreateCache;
60:
61: -- IsCacheCreated
87: l_currIdx := g_Object_List(p_cache_key).Curr_Idx;
88:
89: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
90: wf_log_pkg.string(wf_log_pkg.level_statement,
91: 'wf.plsql.WF_OBJECT_CACHE.Check_Size.Begin',
92: 'Checking size of Cache. CurrIdx {'||l_currIdx||'}');
93: end if;
94:
95: -- Check the current age pointer against max cache size
100:
101: g_Object_List(p_cache_key).Overflow := true;
102: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
103: wf_log_pkg.string(wf_log_pkg.level_statement,
104: 'wf.plsql.WF_OBJECT_CACHE.Check_Size.Begin',
105: 'Curr Idx exceeded Max Cache size, reseting CurrIdx. '||
106: ' Max Cache Size {'||g_cacheMaxSize||'}');
107: end if;
108: end if;
111: if (g_Object_List(p_cache_key).Overflow) then
112: l_oldest := g_Object_List(p_cache_key).Hash_Val(l_currIdx);
113: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
114: wf_log_pkg.string(wf_log_pkg.level_statement,
115: 'wf.plsql.WF_OBJECT_CACHE.Check_Size.Begin',
116: 'Removing oldest record {'||l_oldest||'} from cache');
117: end if;
118: g_Object_List(p_cache_key).Cache_Objs.DELETE(l_oldest);
119: end if;
142: -- Set object would be called only if the required object was not already
143: -- in the cache.
144: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
145: wf_log_pkg.string(wf_log_pkg.level_procedure,
146: 'wf.plsql.WF_OBJECT_CACHE.Assign_Object.Begin',
147: 'Assigning object at {'||p_object_key||'} in cache {'||p_cache_key||'}');
148: end if;
149:
150: g_Object_List(p_cache_key).Cache_Objs(p_object_key) := p_object;
152: l_currIdx := g_Object_List(p_cache_key).Curr_Idx;
153: g_Object_List(p_cache_key).Hash_Val(l_currIdx) := p_object_key;
154: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
155: wf_log_pkg.string(wf_log_pkg.level_statement,
156: 'wf.plsql.WF_OBJECT_CACHE.Assign_Object.Begin',
157: 'Current Idx for age table is {'||l_currIdx||'}');
158: end if;
159:
160: l_currIdx := l_currIdx + 1;
161: g_Object_List(p_cache_key).Curr_Idx := l_currIdx;
162:
163: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
164: wf_log_pkg.string(wf_log_pkg.level_procedure,
165: 'wf.plsql.WF_OBJECT_CACHE.Assign_Object.End',
166: 'Assigned object to cache. Next Idx {'||l_currIdx||'}');
167: end if;
168: end Assign_Object;
169:
186: begin
187:
188: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
189: wf_log_pkg.string(wf_log_pkg.level_procedure,
190: 'wf.plsql.WF_OBJECT_CACHE.SetObject.Begin',
191: 'Setting object {'||p_object_key||'} in cache {'||p_cache_index||'}');
192: end if;
193:
194: l_cacheLoc := p_cache_index;
196:
197: if (isDuplicate(l_cacheLoc, l_objHashVal)) then
198: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
199: wf_log_pkg.string(wf_log_pkg.level_statement,
200: 'wf.plsql.WF_OBJECT_CACHE.SetObject.Overwrite',
201: 'Object already in cache. Overwriting.');
202: end if;
203: -- If the object is already in cache, overwrite it. The new one might be an
204: -- updated one with more information
205: g_Object_List(l_cacheLoc).Cache_Objs(l_objHashVal) := p_object;
206: else
207: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
208: wf_log_pkg.string(wf_log_pkg.level_statement,
209: 'wf.plsql.WF_OBJECT_CACHE.SetObject.Assign',
210: 'Checking cache size and storing object in cache');
211: end if;
212: -- Checks if cache reached max size. If size reached, the oldest
213: -- record in that cache is removed to give space for the new one
218: end if;
219:
220: exception
221: when others then
222: wf_core.context('WF_OBJECT_CACHE', 'SetObject', p_object_key);
223: raise;
224: end SetObject;
225:
226: -- GetObject
239: begin
240:
241: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
242: wf_log_pkg.string(wf_log_pkg.level_procedure,
243: 'wf.plsql.WF_OBJECT_CACHE.GetObject.Begin',
244: 'Getting {'||p_object_key||'} from cache {'||p_cache_index||'}');
245: end if;
246:
247: l_cacheLoc := p_cache_index;
250: if (g_Object_List.EXISTS(l_cacheLoc) and
251: g_Object_List(l_cacheLoc).Cache_Objs.EXISTS(l_objHashVal)) then
252: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
253: wf_log_pkg.string(wf_log_pkg.level_statement,
254: 'wf.plsql.WF_OBJECT_CACHE.GetObject.Cache_Hit',
255: 'Object found in cache for {'||p_object_key||'}');
256: end if;
257: return g_Object_List(l_cacheLoc).Cache_Objs(l_objHashVal);
258: else
257: return g_Object_List(l_cacheLoc).Cache_Objs(l_objHashVal);
258: else
259: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
260: wf_log_pkg.string(wf_log_pkg.level_statement,
261: 'wf.plsql.WF_OBJECT_CACHE.GetObject.Cache_Hit',
262: 'Object not found in cache for {'||p_object_key||'}');
263: end if;
264: return null;
265: end if;
265: end if;
266:
267: exception
268: when others then
269: wf_core.context('WF_OBJECT_CACHE', 'GetObject', p_object_key);
270: raise;
271: end GetObject;
272:
273: -- GetAllObjects
278: l_objs wf_objects_t;
279: begin
280: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
281: wf_log_pkg.string(wf_log_pkg.level_statement,
282: 'wf.plsql.WF_OBJECT_CACHE.GetAllObjects.Begin',
283: 'Returning all cached objects for {'||p_cache_index||'}');
284: end if;
285: return g_Object_List(p_cache_index).Cache_Objs;
286: end GetAllObjects;
294: begin
295:
296: if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
297: wf_log_pkg.string(wf_log_pkg.level_procedure,
298: 'wf.plsql.WF_OBJECT_CACHE.Clear.Begin',
299: 'Clearing object at cache index {'||p_cache_index||'}');
300: end if;
301: -- If cache index is specified, delete only that specified cache
302: if (p_cache_index is not null) then
312: end if;
313:
314: end Clear;
315:
316: end WF_OBJECT_CACHE;