Skip to content

ypinc/abap-caches

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ABAP-Caches

Cache algorithms implementation in ABAP

Algos

Usage:

Include choosen algorithm in your program. Use CREATE_LCL_* macro to define a local class. Provide StructureName, KeyName and CacheSize. Fill in the code to retrieve data in case it wasn't found in a cache (usually DB selection, but can be anything) Close method and class definition.

Later in a program just call the GET method of the defined local class to retrieve data from the cache.

include ypinc_sieve. " SIEVE cache macro
create_lcl_sieve tdevc devclass 512. " create SIEVE cache of TDEVC structures with DEVCLASS key - size 512 entries
    select single * from tdevc into rs_tdevc where devclass = iv_devclass. " data retrival code in case of cache miss 
  endmethod.
endclass.

... Later in a program ...

data(rs_tdevc) = lcl_sieve_tdevc_by_devclass=>get( ls_tadir-devclass ). " get structure from the cache

Benchmarks:

Performed on a local ABAP 2022 Trial installation using YP_BENCH_CACHE report

Cache hitratio benchmark
                                                                                        
 1.000.000   entries from TADIR, caching for TDEVC-DEVCLASS, cache size = 512 entries

Cache type                               Hits       Miss    Hit Ratio %              Time, sec
-----------------------------------------------------------------------------------------------
Naive cache, empty when full            915.149    84.851     91,5149                0,5338070
Naive cache with random eviction        922.883    77.117     92,2883                0,6916430
LRU cache                               925.113    74.887     92,5113                0,6325540
2Q cache (25/75% partition)             926.965    73.035     92,6965                0,8449050
SIEVE cache                             926.956    73.044     92,6956                0,5732030
S3FIFO cache                            927.151    72.849     92,7151                1,7748800

Releases

No releases published

Packages

No packages published

Languages