Skip to content

Commit

Permalink
CACHEBOX-85 #resolve
Browse files Browse the repository at this point in the history
Remove Lock and Double `get` from getOrSet
  • Loading branch information
lmajano committed Nov 29, 2023
1 parent 7d731c9 commit 8af80c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"ColdBox Platform",
"version":"7.3.0",
"version":"7.2.1",
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox/@build.version@/[email protected]@.zip",
"author":"Ortus Solutions <[email protected]>",
"slug":"coldbox",
Expand Down
32 changes: 11 additions & 21 deletions system/cache/AbstractCacheBoxProvider.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -394,27 +394,17 @@ component accessors=true serializable=false {
return target;
}

// else, produce it
lock
name ="GetOrSet.#variables.cacheID#.#arguments.objectKey#"
type ="exclusive"
timeout ="45"
throwonTimeout="true" {
// double lock, due to race conditions
var target = get( 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
);
}
}
// 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 8af80c5

Please sign in to comment.