Sei sulla pagina 1di 27

Copyright www.JDESource.

com

JD Edwards EnterpriseOne C BSFN using Cache

- Ashish Khandelwal

Agenda

 JDE Cache Concept  JDE Cache Programming

 JDE Cache in Action (Program Example)  JDE Cache APIs

Copyright JDE Source

Copyright www.jdesource.com

JDE Cache

What is JDECACHE

Copyright www.jdesource.com

JDE Cache

JDECACHE is
a 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.

Copyright www.jdesource.com

JDE Cache

Why should we use ?

Copyright www.jdesource.com

JDE Cache

Because JDECACHE has faster record access time, efficient & platform independent program architecture. Thus when used properly, it promotes higher performance and better maintainable code.

Copyright www.jdesource.com

Starting JDECACHE

JDECACHE is
implicitly created, managed, and destroyed by the JDB environment, thus before using any JDECACHE APIs, JDB_InitBhvr must be called.

Copyright www.jdesource.com

Defining JDECACHE Structure

Define a Cache Structure


Declare component fields and their data types. These will be used to store data. Usually defined internally at .h file.

Define an index
Indicate which fields in the cache structure will be used to uniquely identify a cache record.

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.
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.

Copyright www.jdesource.com

10

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.
Copyright www.jdesource.com

11

Cache per User

 To initialize a Cache per User, use jdeCacheInit( ).


Cache 1 Cache 2

Inventory Adjustment 1

Inventory Adjustment 2

Inventory Adjustment 3

Inventory Adjustment 4

User 1

User 2

Copyright www.jdesource.com

Cache per Application

 To initialize a Cache per Application, use jdeCacheInitUser( ).

Cache 1

Cache 2

Cache 3

Cache 4

Inventory Adjustment 1

Inventory Adjustment 2

Inventory Adjustment 3

Inventory Adjustment 4

User 1

User 2

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. 3. jdeCacheResetCursor( )

Reset the cursor to point at the fist record.


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.

Copyright www.jdesource.com

23

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
Copyright www.jdesource.com

24

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

Copyright www.jdesource.com

25

Always Ask For Help

Copyright www.jdesource.com

26

Thank you

www.JDESource.com
Ashish.kr.khandelwal@gmail.com
Copyright www.jdesource.com