jd edwards enterpriseone - bsfn cache programming
DESCRIPTION
JD Edwards EnterpriseOne - BSFN Cache ProgrammingTRANSCRIPT
Copyright © www.JDESource.com
JD Edwards EnterpriseOneC BSFN using Cache
- Ashish Khandelwal
Copyright © www.jdesource.comCopyright © JDE Source
Agenda
JDE Cache Concept
JDE Cache Programming
JDE Cache in Action (Program Example)
JDE Cache APIs
2
Copyright © www.jdesource.com
JDE Cache
What is JDECACHE
3
Copyright © www.jdesource.com
JDE Cache
JDECACHE isa component of JDEKRNL that can hold any type of indexed data that your application needs to store in memory(RAM). This is primary used in Application developments.
4
Copyright © www.jdesource.com
JDE Cache
Why should we use ?
5
Copyright © www.jdesource.com
JDE Cache
Because JDECACHE has faster record accesstime, efficient & platform independentprogram architecture. Thus when used properly, it promotes higher performance and better maintainable code.
6
Copyright © www.jdesource.com
Starting JDECACHE
JDECACHE isimplicitly created, managed, and destroyed by the JDB environment, thus before using any JDECACHE APIs, JDB_InitBhvr must be called.
7
Copyright © www.jdesource.com
Defining JDECACHE Structure
Define a Cache StructureDeclare component fields and their data
types. These will be used to store data. Usually defined internally at .h file.
Define an indexIndicate which fields in the cache structure
will be used to uniquely identify a cache record.
8
Copyright © www.jdesource.com
Cache Index
Index Structure holds the key value(s) of the record being searched
Index Definition is a series of offsets, sizes, and data types
Use same Data Structure template for the index that was used for the cache. Must match since index is based on offsets.
JDECACHE uses the actual record set stored in the cache as the index structure. JDECACHE record has a dual purpose of index storage and data storage.
9
Copyright © www.jdesource.com
Initializing JDECACHE
Before any cache can be used, it must be initialized by calling a JDECACHE API. The initialization APIs will require the cache structure, index, name, and the hUser handle.
10
Copyright © www.jdesource.com
Initializing JDECACHE
– Cache per User
A cache is unique per user. When a user logs onto OneWorld and runs an application twice at the same time, the two instances of the application will share the same cache memory for that user.
– Cache per Application
A cache is unique per user per application. When a user logs onto OneWorld and runs an application twice at the same time, each instance of the application will have its own cache memory for that user.
11
Copyright © www.jdesource.com
Cache per User
To initialize a Cache per User, use jdeCacheInit( ).
User1
Inventory Adjustment 1
InventoryAdjustment 2
Cache 1
User2
Inventory Adjustment 3
InventoryAdjustment 4
Cache 2
Copyright © www.jdesource.com
Cache per Application
To initialize a Cache per Application, use jdeCacheInitUser( ).
User 1
InventoryAdjustment 1
InventoryAdjustment 2
Cache 1 Cache 2
User 2
InventoryAdjustment 3
InventoryAdjustment 4
Cache 3 Cache 4
Copyright © www.jdesource.com
Initializing JDECACHE
Cache Index or Indices Consideration
– Single Cache Index
A cache with single index. The most common and the prevailing way to initialize a cache. Gives best performance and requires minimum memory.
– Multiple Cache Indices
A cache with multiple indices (2 or more). No limitation on the number of indices you can have, but normally we do not exceed 25 for performance and memory reasons.
Copyright © www.jdesource.com
Cache Initialization APIs
If the cache does not exist, create a new cache. If the cache does exist, return a cache handle
that points to the existing cache. APIs
– jdeCacheInit( )– jdeCacheInitEx()– jdeCacheInitMultipleIndexEx()– jdeCacheInitMultipleIndex( )
– jdeCacheInitUser( )– jdeCacheInitMultipleIndexUser( )
Copyright © www.jdesource.com
Cache Cursor
Cache Cursor is
– A pointer to a cache record.
– You must have a cursor to the record you want to manipulate beforehand.
– A cursor advances automatically when you fetch next record.
– We only allow maximum 100 cursors can be opened per cache.
Copyright © www.jdesource.com
Cursor Manipulations
1. jdeCacheOpenCursor( )• Creates/opens a cursor that will point to
the first record in cache. Open cursor will fail if a cache contains no record
2. jdeCacheResetCursor( )• Reset the cursor to point at the fist
record.3. jdeCacheCloseCursor( )
• Close a cursor. This API should be matched with every jdeCacheOpenCursor called to prevent internal memory leak and the potential of reaching the 100 cursors limit.
Copyright © www.jdesource.com
Cache Manipulation (R.A.U.D.T)
Cache Read
Cache Add / Update
Cache Delete
Cache Terminate
Copyright © www.jdesource.com
Cache Read
1. jdeCacheFetchPosition( )• This API supports full and partial key search.• Set an opened cursor point at the desired
record in cache. • The first record that matches the key will be
returned.• Return a copied data
2. jdeCacheFetch ( )• Move the cursor to the next position.• Return a copied data
3. jdeCacheFetchPositionByRef ( )• Return the pointer to the one and only one
large record in cache. You have the direct access to the record.
Copyright © www.jdesource.com
Cache Add/Update
It is always a good practice to add or update record with the same size.
– Adding a cache record – jdeCacheAdd( )
– Updating a cache record – jdeCacheUpdate ( )
Copyright © www.jdesource.com
Cache Delete
1. jdeCacheDelete( )• Delete a record from cache that matched
the key.2. jdeCacheDeleteAll( )
• Delete all records from cache that match the key.
3. jdeCacheClear( )• Delete all records in cache.
Copyright © www.jdesource.com
Cache Termination
1. jdeCacheTerminate( )• Terminate a cache handle.• All records in the cache will be deleted and
all opened cursors will be closed if this is the last cache handle (same cache name).
2. jdeCacheTerminateAll( )• Terminate all active caches (same cache
name).• All records in the cache will be deleted and
all opened cursors will be closed.
Copyright © www.jdesource.com
JDECacheInit/JDECacheTerminate Rule
For each Cache Init, there must be a Cache Terminate.
A jdeCacheTerminate call terminates the most recent corresponding jdeCacheInit.
When the number of jdeCacheTerminate calls match the jdeCacheInit calls, the memory is released. Otherwise, only the association between the cache and the HCACHE handle is destroyed.
23
Copyright © www.jdesource.com
Miscellaneous
– jdeCacheGetNumCursors• short int jdeCacheGetNumCursors(HCACHE
hCache)• Return total number of opened cursors in a cache.
– jdeCacheGetNumRecords• long int jdeCacheGetNumRecords(HCACHE
hCache)• Return total number of records in a cache.
– jdeCacheGetIndex• long int jdeCacheGetIndex(HCACHE hCache,
HJDECURSOR hCursor)• Return the index ID number for a cursor.
– jdeCacheSetIndex• JDECM_RESULT jdeCacheSetIndex(HCACHE
hCache, HJDECURSOR hCursor, long int nIndexID)
• Set the specified indexID of the current cursor, which will be used to sort the data
24
Copyright © www.jdesource.com
Cache Spy
Set CacheToSpy in client ini file [JDECACHE SETTINGS]
CacheToSpy=ALL This utility helps to print out the detail cache
information Ouput file :\\system\bin32\jdeCacheSpy.log
25
Copyright © www.jdesource.com26
Always Ask For Help
Copyright © www.jdesource.com
Thank you
www.JDESource.com