I use a lot of caching in my development and recently came across two bugs that I'd like to report to OpenText development.
The first bug is in $LLIAPI.CacheUtil.Update() in the part that invalidates the memached values:
// Invalidate the cache so that next access will request new data from the databaseif ( ok ) checkVal = $LLIAPI.MemcachedUtil.DeleteKey( prgCtx, .fMemcachedNamespace, objectID ) if ( checkVal.ok != TRUE ) EchoWarn( checkVal.errMsg ) endend
The code has no error handling if the $LLIAPI.MemcachedUtil.DeleteKey() call fails for any reason. This results in the subsequent $LLIAPI.CacheUtil.Load() call returning stale values rather than reloading the new values from the database. A possible fix is to roll back the transaction and return an error when the DeleteKey() call fails.
The second bug is with memcached. It seems Undefined can be stored as a value in memcached, but the $LLIAPI.MemcachedUtil.GetValue() call interprets this not being found (i.e., by returning found=false). For example:
Assoc resultsString namespace = "MyNamespace"String key = "MyKey"results = $LLIAPI.MemcachedUtil.GetValue(prgCtx, namespace, key)echo(results.found)// false, because a value hasn't been cached yet// cache an undefined value$LLIAPI.MemcachedUtil.SetValue(prgCtx, namespace, key, Undefined)results = $LLIAPI.MemcachedUtil.GetValue(prgCtx, namespace, key)echo(results.found)// still false, although the Undefined value was stored and returned from memcached
I think Undefined should be a valid cache value since it has application in, say, caching database values that are null.
Thanks!