transactions

Redis - Using Incr value in a transaction

筅森魡賤 提交于 2021-02-06 09:20:43
问题 Is it possible to use multi.incr(value) with multi.hmset ? I mean: var name = 'Josh'; var multi = client.multi(); multi.incr('id'); // incr => 1 multi.hmset('user:' + <need incr value here>, 'username', name); // I want multi.hmset('user:1', 'username', 'Josh'); multi.exec(function(err,data){ .. }); My objective is to increment 'id', and then set it to a user id in a transaction. I have read, that i need to do client.watch('id') , but i don't understand how to use it. PD: Please, post your

Redis - Using Incr value in a transaction

戏子无情 提交于 2021-02-06 09:19:34
问题 Is it possible to use multi.incr(value) with multi.hmset ? I mean: var name = 'Josh'; var multi = client.multi(); multi.incr('id'); // incr => 1 multi.hmset('user:' + <need incr value here>, 'username', name); // I want multi.hmset('user:1', 'username', 'Josh'); multi.exec(function(err,data){ .. }); My objective is to increment 'id', and then set it to a user id in a transaction. I have read, that i need to do client.watch('id') , but i don't understand how to use it. PD: Please, post your

How do I prevent exceptions from causing a transaction rollback under Grails?

佐手、 提交于 2021-02-06 08:51:14
问题 My Grails service is having an issue where a swallowed exception unrelated to a transaction is causing the transaction to rollback even when it is unrelated to the persistance of the domain object. In my service I have something along the lines of updateSomething(domainObj) { def oldFilename = domainObj.filename def newFilename = getNewFilename() domainObj.filename = newFilename domainObj.save(flush: true) try { cleanUpOldFile(oldFilename) } catch (cleanupException) { // oh well, log and

How do I prevent exceptions from causing a transaction rollback under Grails?

孤人 提交于 2021-02-06 08:49:58
问题 My Grails service is having an issue where a swallowed exception unrelated to a transaction is causing the transaction to rollback even when it is unrelated to the persistance of the domain object. In my service I have something along the lines of updateSomething(domainObj) { def oldFilename = domainObj.filename def newFilename = getNewFilename() domainObj.filename = newFilename domainObj.save(flush: true) try { cleanUpOldFile(oldFilename) } catch (cleanupException) { // oh well, log and

Why does TRANSACTION / COMMIT improve performance so much with PHP/MySQL (InnoDB)?

别来无恙 提交于 2021-02-05 17:59:03
问题 I've been working with importing large CSV files of data; usually less than 100,000 records. I'm working with PHP and MySQL (InnoDB tables). I needed to use PHP to transform some fields and do some text processing prior to the MySQL INSERT s (part of process_note_data() in code below). MySQL's LOAD DATA was not feasible, so please do not suggest it. I recently tried to improve the speed of this process by using MySQL transactions using START TRANSACTION and COMMIT . The performance increase

Why does TRANSACTION / COMMIT improve performance so much with PHP/MySQL (InnoDB)?

不问归期 提交于 2021-02-05 17:55:34
问题 I've been working with importing large CSV files of data; usually less than 100,000 records. I'm working with PHP and MySQL (InnoDB tables). I needed to use PHP to transform some fields and do some text processing prior to the MySQL INSERT s (part of process_note_data() in code below). MySQL's LOAD DATA was not feasible, so please do not suggest it. I recently tried to improve the speed of this process by using MySQL transactions using START TRANSACTION and COMMIT . The performance increase

C# System.Transactions Vs TransactionScope

﹥>﹥吖頭↗ 提交于 2021-02-05 09:24:26
问题 Based on this article here as well as the question: Difference Between Transaction and TransactionScope we know that TransactionScope The TransactionScope class provides a simple way to mark a block of code as participating in a transaction, without requiring you to interact with the transaction itself. A transaction scope can select and manage the ambient transaction automatically. Due to its ease of use and efficiency, it is recommended that you use the TransactionScope class when

Pricing when updating more than one field of the same document within a Firestore transaction

让人想犯罪 __ 提交于 2021-02-05 08:15:26
问题 I have the following transaction using Firestore: mDb.runTransaction(new Transaction.Function<Void>() { @Override public Void apply(final Transaction transaction) throws FirebaseFirestoreException { DocumentReference documentReference = mDb.collection("collectionOne").document("documentOne"); /* some code */ transaction.update(documentReference, App.getResourses().getString(R.string.field_one), FieldValue.increment(1)); transaction.update(documentReference, App.getResourses().getString(R

Pricing when updating more than one field of the same document within a Firestore transaction

杀马特。学长 韩版系。学妹 提交于 2021-02-05 08:11:04
问题 I have the following transaction using Firestore: mDb.runTransaction(new Transaction.Function<Void>() { @Override public Void apply(final Transaction transaction) throws FirebaseFirestoreException { DocumentReference documentReference = mDb.collection("collectionOne").document("documentOne"); /* some code */ transaction.update(documentReference, App.getResourses().getString(R.string.field_one), FieldValue.increment(1)); transaction.update(documentReference, App.getResourses().getString(R

Locking and concurrency with MySQL

扶醉桌前 提交于 2021-02-05 07:27:25
问题 I'm currently using Mysql with InnoDB storage engine for all tables. So, I'm wondering if this is a real problem and if there's a solution for it. For example, I will charge a user using a database transaction: 1. check his balance 2. subtract his balance 3. credit this balance somewhere 4. commit What would happen if an update happens just after #1 and before 2 & 3. If the user withdraws or purchases something else that results his balance to be zero. This would have led to to lose that