You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix fo PHPORM-99
In theory, we can use DatabaseStore and DatabaseLock. But various issues prove the changing nature of their implementation, based on new features in the query builder, make this feature unstable for MongoDB users. fix#2718, fix#2609
By introducing dedicated drivers, we can optimize the implementation to use the mongodb library directly instead of the subset of features provided by Laravel query builder.
Usage:
# config/cache.php
return [
'stores' => [
'mongodb' => [
'driver' => 'mongodb',
'connection' => 'mongodb',
'collection' => 'cache',
'lock_connection' => 'mongodb',
'lock_collection' => 'cache_locks',
'lock_lottery' => [2, 100],
'lock_timeout' => '86400',
]
]
]
Cache:
// Store any value into the cache. The value is serialized in MongoDB
Cache::set('foo', [1, 2, 3]);
// Read the value
dump(Cache::get('foo'));
// Clear the cache
Cache::flush();
Lock:
// Get an unique lock. It's very important to keep this object in memory
// so that the lock can be released.
$lock = Cache::lock('foo');
$lock->block(10); // Wait 10 seconds before throwing an exception if the lock isn't released
// Any time-consuming task
sleep(5);
// Release the lock
$lock->release();
Description:
The implementation of Cache's put function is modified to db's upsert function in Laravel10.

Steps to reproduce
When the driver of cache is changed to mongodb,This will lead to an error. Such as this:
The error is: This database engine does not support upserts.
The text was updated successfully, but these errors were encountered: