<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Asif Rahman on Medium]]></title>
        <description><![CDATA[Stories by Asif Rahman on Medium]]></description>
        <link>https://medium.com/@rahmanasif05004?source=rss-af894e6cad45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g_WJHNuppV7OMtUqSx2vQg.jpeg</url>
            <title>Stories by Asif Rahman on Medium</title>
            <link>https://medium.com/@rahmanasif05004?source=rss-af894e6cad45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:13:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahmanasif05004/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Commit vs. Rollback: Database Transaction Essentials]]></title>
            <link>https://medium.com/@rahmanasif05004/commit-vs-rollback-database-transaction-essentials-cb8765c02ceb?source=rss-af894e6cad45------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb8765c02ceb</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[transactions]]></category>
            <category><![CDATA[rollbacks]]></category>
            <category><![CDATA[acid]]></category>
            <dc:creator><![CDATA[Asif Rahman]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 19:25:32 GMT</pubDate>
            <atom:updated>2024-10-21T06:20:15.429Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*RRMqaEdHaLj7WreK.png" /></figure><p>In the world of databases, transactions are akin to journeys-comprising a series of steps or operations performed as a single, cohesive unit of work. Whether you’re booking a flight, ordering groceries online, or transferring funds between accounts, transactions play a vital role in ensuring that database operations are reliable, consistent, and resilient. Let’s take on a journey through the commit and rollback processes in database transactions, exploring each step with relatable analogies to make the journey more understandable, followed by the technical details.</p><h3>The Commit Process</h3><h3>1. Initiating the Journey: Begin Transaction</h3><h4>Analogy:</h4><p>Think of it as the moment you decide to embark on a trip. You gather your essentials and map out your route before setting off. This planning phase ensures that you’re prepared for the journey ahead.</p><h4>Technical Detail:</h4><p>A transaction begins with the BEGIN TRANSACTION statement. This marks the start of a series of operations that must be executed atomically. All changes made during the transaction are initially tentative and only become permanent upon commit.</p><h3>2. Logging the Voyage: Write-Ahead Logging (WAL)</h3><h4>Analogy:</h4><p>Before setting sail, it’s wise to create a list of everything you’re bringing along. Similarly, the WAL records all changes made by the transaction in a log before they’re applied to the database. This log serves as a safety net, allowing for recovery in case of unforeseen circumstances-much like referring back to your list if you forget something during your journey.</p><h4>Technical Detail:</h4><p>Before making any changes to the database, the system writes these changes to a write-ahead log (WAL). The WAL is a sequential record of all modifications. By logging changes before they are applied, the database can ensure durability and support recovery in case of a crash.</p><h3>3. Planning the Itinerary: In-Memory Data Modification</h3><h4>Analogy:</h4><p>With your journey underway, you begin planning your itinerary and mentally preparing for the adventure. It’s akin to mapping out your route and making mental notes of the places you’ll visit before physically setting foot on your journey.</p><h4>Technical Detail:</h4><p>Changes are initially made in-memory, within the database’s buffer cache. This allows for quick response times and reduces the immediate need for disk I/O. The in-memory data structures are updated first, and these changes are later propagated to the disk.</p><h3>4. Securing the Record: Log Flush</h3><h4>Analogy:</h4><p>Just as you ensure your list is safely stored in your backpack before hitting the road, the database flushes the log entries to disk to ensure they’re durably recorded. This step guarantees that there’s a persistent record of the transaction’s changes, providing a safety net in case of unexpected detours or interruptions along the way.</p><h4>Technical Detail:</h4><p>The log entries recorded in the WAL are flushed to disk to ensure their durability. This means writing the log entries from memory to stable storage, ensuring that they are not lost even if there is a system crash.</p><h3>5. Confirming the Voyage: Commit Record</h3><h4>Analogy:</h4><p>As you progress on your journey and decide to commit to the adventure, you officially confirm your plans by signing your name on a travel document. Similarly, in a database, a special commit record is written to the log to mark the transaction as complete. This commitment ensures that the changes made by the transaction are finalized and applied to the database.</p><h4>Technical Detail:</h4><p>A commit record is written to the WAL to indicate that the transaction has been successfully completed. This commit record marks the point at which all changes made by the transaction become permanent.</p><h3>6. Ensuring Durability: Data Page Flush (Deferred)</h3><h4>Analogy:</h4><p>While you’ve committed to your journey, you may not immediately load all your belongings onto the transport. Similarly, in a database, modified data pages in the buffer cache are eventually flushed to disk, but not necessarily immediately. This delayed flushing optimizes performance while still ensuring durability, much like waiting for the right moment to load your belongings for maximum efficiency.</p><h4>Technical Detail:</h4><p>While the commit ensures the changes are durable, the actual data pages containing the changes might not be immediately written to disk. The database employs a lazy writing strategy, flushing these pages to disk at a later time, optimizing for performance.</p><h3>The Rollback Process</h3><h3>1. Identifying Uncommitted Changes: Identifying Mistakes in Your List</h3><h4>Analogy:</h4><p>Suppose you suddenly realize you’ve forgotten to pack something essential. You identify the items you haven’t packed yet. In a database, this means identifying changes made by the transaction that need to be undone.</p><h4>Technical Detail:</h4><p>If a transaction needs to be rolled back, the database first identifies all changes made by the transaction that have not been committed. This involves scanning the WAL to find all operations that need to be undone.</p><h3>2. Undo Log Entries: Erasing Mistakes</h3><h4>Analogy:</h4><p>You refer back to your packing list to see what items you haven’t yet packed and need to remove. Similarly, in a database, undo log entries are used to find information to undo each change made by the transaction.</p><h4>Technical Detail:</h4><p>The database uses the WAL to undo each change made by the transaction. For each operation recorded in the WAL, a corresponding undo operation is performed to revert the data to its previous state.</p><h3>3. Apply Undo Operations: Fixing Mistakes</h3><h4>Analogy:</h4><p>You unpack the items you previously packed incorrectly, ensuring you’re only taking what you need for the trip. In a database, undo operations are applied to in-memory data structures to reverse the changes made by the transaction.</p><h4>Technical Detail:</h4><p>The database applies the undo operations to the in-memory data structures, effectively rolling back the changes. This ensures that the database is returned to its state prior to the start of the transaction.</p><h3>4. Log Rollback: Recording the Change of Plans</h3><h4>Analogy:</h4><p>You make a note in your travel log that you’ve decided not to proceed with the trip, keeping a record of the change in plans. Similarly, in a database, a rollback log entry indicates that the transaction was rolled back.</p><h4>Technical Detail:</h4><p>A rollback log entry may be written to indicate that the transaction has been rolled back. This helps in maintaining an accurate log for recovery purposes.</p><h3>5. Release Locks: Freeing Resources</h3><h4>Analogy:</h4><p>Any reservations or bookings you made for the trip are canceled, freeing up resources for others to use. In a database, releasing locks ensures that other transactions can access the database and make changes without any problems.</p><h4>Technical Detail:</h4><p>Any locks held by the transaction on database objects are released. This allows other transactions to access these objects and proceed with their operations.</p><h3>Conclusion:</h3><p>In the domain of databases, transactions are like well-planned voyages. Just as you prepare for a trip by packing your essentials and mapping out your route, databases begin transactions by organizing the changes they need to make.</p><p>During transaction’s journey, data changes are logged so that nothing gets lost along the way. For example, this log acts as a safety net for databases helping them in recovering after something unexpected happens.</p><p>When it is time for a transaction to be committed, it’s just like finalizing plans and making them official. The database ensures all changes are securely saved.</p><p>However, if there is an error and a rollback is required it’s just like changing your mind about taking a journey after all. The database cancels out any modifications made by the transaction and restores everything back to how it was before.</p><p>Releasing locks at the end of a transaction is like canceling reservations freeing up resources for others to use.</p><p>Understanding these processes will help you maintain smooth running of your database systems, reliable data, consistent operations. Whether using apps or shopping online or managing finances those background processes matter which can keep thing running smoothly. Thus next time you communicate with a data base remember committing and rolling back- ensuring you</p><p><em>Originally published at </em><a href="https://dev.to/asifzcpe/demystifying-database-transactions-how-commit-and-rollback-ensure-smooth-data-handling-2mo2"><em>https://dev.to</em></a><em> on June 25, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb8765c02ceb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Single method accessors and mutators in laravel]]></title>
            <link>https://medium.com/@rahmanasif05004/single-method-accessors-and-mutators-in-laravel-5b434a05a16?source=rss-af894e6cad45------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b434a05a16</guid>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[laravel-latest]]></category>
            <category><![CDATA[whats-new]]></category>
            <category><![CDATA[accessor-mutator]]></category>
            <category><![CDATA[new-in-laravel]]></category>
            <dc:creator><![CDATA[Asif Rahman]]></dc:creator>
            <pubDate>Mon, 27 Dec 2021 16:05:21 GMT</pubDate>
            <atom:updated>2021-12-27T16:05:21.697Z</atom:updated>
            <content:encoded><![CDATA[<p>We have already known the usage of accessors and mutators. We use accessors in laravel model to modify any field data while retrieving the records and mutators to modify any field data while inserting to database.</p><p>So, to modify any field before, we needed two separate methods for a single filed i.e. one method for accessor and one for mutator but in latest laravel release I mean in laravel 8.77.0, we can use a single method for both accessor and mutator using closure .</p><p>Given below is the syntax for single mehtod accessor and mutator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*vzqN2gKURfoak_YelIYGTA.png" /></figure><p>In the above closures, the first closure is for accessor and the next for mutator.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b434a05a16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[configuring webpack with vanilla js]]></title>
            <link>https://medium.com/@rahmanasif05004/configuring-webpack-with-vanilla-js-220dd5be37ab?source=rss-af894e6cad45------2</link>
            <guid isPermaLink="false">https://medium.com/p/220dd5be37ab</guid>
            <category><![CDATA[webpack-tutorial]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[webpack-initialization]]></category>
            <category><![CDATA[webpack-with-vanilla-js]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Asif Rahman]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 11:32:17 GMT</pubDate>
            <atom:updated>2018-07-31T11:32:17.970Z</atom:updated>
            <content:encoded><![CDATA[<p>To put it simple, wabpack is a tool for module bundling. Here, I am not gonna saying more details about whats and hows of webpack. Here, I will show you how to use webpack in vanilla js.</p><ol><li>Install webpack and webpack-cli with the following commands into your project directory:</li></ol><pre>npm install -s webpack<br>npm install -s webpack-cli</pre><p>2. Create a folder and into it create a webpack configuration file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*JXIJMZzXkVNazBsLnRPjrw.png" /></figure><p>3. after it, go to project directory using cmd/terminal tools and run the following command and fulfill the following info although not all are necessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*PTp5PQNT9Uc34eBjXZ3lOg.png" /></figure><p>This will create a package.json file into your project folder.Go to this package.json file and write the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*TvbOgGDsrAWit71l-PjMhg.png" /></figure><p>4. Next, we need to write some code in <strong>webpack.config.js</strong> to instruct <strong>webpack </strong>how to bundle our js and other scripts in the following way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*bkw8kwuPKln9iGX19F3AqQ.png" /></figure><p>Here <strong>entry</strong> is your bootstrap file that is the starter of your app; can be anything and <strong>filename </strong>is the bundled file created by webpack. You can give it any name you want.</p><p>5. Now, let’s go to put some codes in app.js files and create some other scripts.</p><p>Finally, run <strong>npm start </strong>and it will create bundle.js file into dist folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*Xp8Z5PQlU6hXzQnbUu-eMw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=220dd5be37ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Custom Directives With Blade Engine In Laravel:]]></title>
            <link>https://medium.com/@rahmanasif05004/making-custom-directives-with-blade-engine-in-laravel-9e08cf378796?source=rss-af894e6cad45------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e08cf378796</guid>
            <category><![CDATA[custom-directive]]></category>
            <category><![CDATA[directives]]></category>
            <category><![CDATA[laravel-custom-directive]]></category>
            <category><![CDATA[laravel-directive]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Asif Rahman]]></dc:creator>
            <pubDate>Wed, 09 May 2018 06:08:48 GMT</pubDate>
            <atom:updated>2018-05-09T06:08:48.159Z</atom:updated>
            <content:encoded><![CDATA[<p>While working with blade view in laravel, we use different types of directives provided by laravel. For example: <strong>@if,@foreach,@section </strong>etc. We can make our custom directives in laravel in the following way:</p><p>Directive Code Format:</p><blockquote><strong>Blade::directive(‘directive_name’, function ($expression) {</strong></blockquote><blockquote><strong>return $expression;</strong></blockquote><blockquote><strong>});</strong></blockquote><p><strong>Example:1 Adding greetings to a persons name.(</strong> Passing single parameter<strong>)</strong></p><p>Step1: Go to your <strong>app/Providers/AppServiceProvider.php </strong>and write the following codes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*cdYDy8ATzckaFi3B6emsig.png" /><figcaption>Passing single parameter</figcaption></figure><p>Step:2 Go to any of view file and use the newly added directive in the following way and get the output in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*-1_A4q9z0laYVRRR8t_AjA.png" /></figure><p><strong>Example:2 Changing Date Format with the provided format(</strong>Passing multiple parameters<strong>)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*wrCHLH6mhQBURhBWA7DGnQ.png" /><figcaption>Passing multiple parameters</figcaption></figure><p>It’s done!!!!!!! Hope, It may help you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*YppecaHsXgorUU2rHY8j0A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e08cf378796" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Query Listener]]></title>
            <link>https://medium.com/@rahmanasif05004/laravel-query-listener-8a2d62d7d460?source=rss-af894e6cad45------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a2d62d7d460</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[query-listener]]></category>
            <category><![CDATA[laravel-query-listener]]></category>
            <category><![CDATA[query-tracing]]></category>
            <category><![CDATA[how-to-know-query-time]]></category>
            <dc:creator><![CDATA[Asif Rahman]]></dc:creator>
            <pubDate>Fri, 04 May 2018 08:43:13 GMT</pubDate>
            <atom:updated>2018-05-04T08:44:05.378Z</atom:updated>
            <content:encoded><![CDATA[<p>In laravel app, sometime we need to trace the query that is run on the server to fetch data. It is useful for a developer to trace the each query run on the server and the time it takes to be executed.</p><p>We can do this using DB Listen method in routes/web.php provided by Laravel Framework. Following is the way how to do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*y5gKUHEoM_BzuX0lTLrVLA.png" /></figure><p>Now, run any page that executes query and you will get query log into your laravel.log file like below.</p><p>It’s so simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*6OyzAVkaHM4JxQBBENL4QA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a2d62d7d460" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Separating Routes in Laravel]]></title>
            <link>https://medium.com/@rahmanasif05004/separating-routes-in-laravel-ed0057de840b?source=rss-af894e6cad45------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed0057de840b</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[separate-roue-file]]></category>
            <category><![CDATA[laravel-routes]]></category>
            <dc:creator><![CDATA[Asif Rahman]]></dc:creator>
            <pubDate>Sun, 29 Apr 2018 18:04:03 GMT</pubDate>
            <atom:updated>2019-04-12T04:32:55.474Z</atom:updated>
            <content:encoded><![CDATA[<p>while developing large laravel app, sometimes our route file gets very large and unmanageable. It is quite tough to manage large route file containing many routes.</p><p>We can come out of this problem by separating our route files.For example, we have 3 modules naming Sales,Accounts, Employee. we can generate 3 routes file in routes folder in the following way.</p><p>Step1-create route files related to your module. Here, I created <strong>accounts.php, sales.php and employee.php</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*zkAETy0qCR-kz-87AlteEg.png" /></figure><p>Step2-Open RouteServiceProvider.php file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*YzEfFFlFmvEtAveccU8apA.png" /></figure><p>Step3- create a funtion like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*vTAAIKNEcqKYFMC8MkwDrQ.png" /></figure><p><strong>Note</strong>: Here, you can add middleware, prefix as par your need.</p><p>Step4-To call the method in map() method like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*MI5LFzgoMsNgOafv20kI0g.png" /></figure><p>Its done!!!!!!!!</p><p>Now, you can write any route in the newly generated route files(like accounts.php,sales.php and employee.php)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed0057de840b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>