Skip to content

Commit

Permalink
CACHEBOX-85 #resolve
Browse files Browse the repository at this point in the history
Improve Lock and Double `get` from getOrSet
  • Loading branch information
lmajano committed Dec 11, 2023
1 parent 0a3d6e0 commit cd43133
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions system/cache/AbstractCacheBoxProvider.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,26 @@ component accessors=true serializable=false {
return target;
}

// produce it
target = arguments.produce();

// store it
set(
objectKey = arguments.objectKey,
object = target,
timeout = arguments.timeout,
lastAccessTimeout = arguments.lastAccessTimeout,
extra = arguments.extra
);
lock
name ="GetOrSet.#variables.cacheID#.#arguments.objectKey#"
type ="exclusive"
timeout ="45"
throwonTimeout="true" {
// double production check
var target = getQuiet( arguments.objectKey );
if ( isNull( local.target ) ) {
// produce it
target = arguments.produce();
// store it
set(
objectKey = arguments.objectKey,
object = target,
timeout = arguments.timeout,
lastAccessTimeout = arguments.lastAccessTimeout,
extra = arguments.extra
);
}
}

return target;
}
Expand Down

0 comments on commit cd43133

Please sign in to comment.