<?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 Samayun Miah Chowdhury on Medium]]></title>
        <description><![CDATA[Stories by Samayun Miah Chowdhury on Medium]]></description>
        <link>https://medium.com/@samayun?source=rss-39ef8cdf061a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zivH8rI2xoQSPn_8ybmQKQ.png</url>
            <title>Stories by Samayun Miah Chowdhury on Medium</title>
            <link>https://medium.com/@samayun?source=rss-39ef8cdf061a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:44:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samayun/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[রেডিস কথন ৪]]></title>
            <link>https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%AA-594c4c4d2725?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/594c4c4d2725</guid>
            <category><![CDATA[redis-geospatial-index]]></category>
            <category><![CDATA[redis-bangla]]></category>
            <category><![CDATA[redis-leaderboard]]></category>
            <category><![CDATA[redis-sorted-set]]></category>
            <category><![CDATA[redis-usecase]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 09:03:53 GMT</pubDate>
            <atom:updated>2023-08-08T09:03:53.544Z</atom:updated>
            <content:encoded><![CDATA[<p>ঢাকায় গাছের চেয়ে রেস্টুরেন্ট বৃদ্ধির হার অধিক ৷</p><p>কাছের ভালো রেস্টুরেন্ট রিকমান্ডেশনে রেডিসের ভুমিকা</p><p>আজকে আমরা রেডিসের আরো ইউজকেস নিয়ে আলোচনা করবো। সিরিজের আগের ব্লগ মিস হয়ে গেলে, কমেন্ট থেকে খুজে নিন…</p><p><em>Previous Blog:</em> <a href="https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%A9-b733cb4bd3f0">#রেডিস কথন ৩</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aWZS9yQww03mouup.png" /></figure><h4>1. LeaderBoard</h4><p>Kahoot নামে একটা ওয়েবসাইট আছে কুইজ গেম খেলা যায়, যেকোনো মাল্টি প্লেয়ার গেমেই টপ স্কোরার লিস্ট থাকে ।</p><p>আপনার এপ্লিকেশনে ৫০ টি গেম আছে, ৫০ টি গেমের ই লিডারবোর্ড শো করাবেন ইউজারকে ।</p><p>ডাটাবেজ থেকে কুয়েরী করলে কী ঘটবে এখন বুঝতেছেন ??</p><p>সকেট দিয়ে কানেক্ট করে এত্তোগুলো কুয়েরী করতে থাকবেন….?</p><p>নাকি টাইম সিরিজ ফিচার ইউজ করবেন??</p><p>যে মেথড ই ফলো করেন Constant Complexity আছে তো?</p><p>রেডিসের রয়েছে নিজস্ব বিল্ট ইন সর্টেড সেট নামক ডাটা টাইপ ।</p><p>স্কোরিং কিংবা ভ্যালু দিয়েও সর্ট করা যায়।</p><p>কি-ভ্যালু ফরম্যাটে ডাটা থাকায় ৫০ গেম কে ৫০ টা কন্সটেন্ট কম্পলেক্সিটি ওয়ালা কুয়েরীতেই ফেচ করা যাবে |</p><p>আর গেম এর স্কোর গুলা স্কোরিং কর‍তে থাকবে। এখানে পাব-সাব প্যাটার্ন ফলো করতে পারেন |</p><p>সেট মানেই তোহ ইউনিক ডাটার সমাহার।</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/0*JPChZMinGv1Ei7TN.png" /></figure><p>যেহেতু এটি সর্টেড সেট চাইলেই রিয়াল টাইম রিকমান্ডেশন সিস্টেম কিন্তু বানানোই যায়?</p><p>কি বলেন??</p><h4>2. Geospatial Indexes</h4><p>লোকেশন বেজড ফিচার ইম্পিমেন্টেশন এর জন্য ইউজড হয় । কমন ফিচার যেমন: estimating distance, arrival times, and nearby রিকমান্ডেশন ৷</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/0*nzffz_H_H9tejkfH" /></figure><p>এটি মুলত সর্টেড সেট ইউজ করে বিহাইন্ড দ্যা সিন ( I might be wrong! )</p><p>নিজের বাসা থেকে গার্লফ্রেন্ডের বাসার দুরত্ব কত মাইল।</p><p>কত কি:মি: হেটে গিয়ে ফুল কিনতে হবে,</p><p>সবচেয়ে কাছের রেস্টুরেন্টের দূরত্ব কতটুকু রিয়াল টাইম ইম্পলিমেন্ট করতে জানতে আজই রেডিস শেখা শুরু করুন…..</p><p>ধন্যবাদ |</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=594c4c4d2725" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[রেডিস কথন ৩]]></title>
            <link>https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%A9-b733cb4bd3f0?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b733cb4bd3f0</guid>
            <category><![CDATA[bullmq]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[queue]]></category>
            <category><![CDATA[redis-pub-sub]]></category>
            <category><![CDATA[redis-usecase]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 08:48:18 GMT</pubDate>
            <atom:updated>2023-08-08T08:50:35.183Z</atom:updated>
            <content:encoded><![CDATA[<p>ডেভলপার জীবনে রেডিসের ভুমিকা</p><p><em>Previous Blog:</em> <a href="https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%A8-66d0f6cb862b">#রেডিস_কথন </a>২</p><p>আজকে আমরা রেডিসের আরো ইউজকেস নিয়ে আলোচনা করবো। সিরিজের আগের ব্লগ মিস হয়ে গেলে, কমেন্ট থেকে খুজে নিন…</p><h4>1. Queue</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IIdZwyuNHvbnDTpU.png" /></figure><p>ফেইসবুক, ইউটিউবে প্রতিনিয়ত ফাইল আপলোড করা খুবই কমন কাজ । ধরেন অনেক ইউজার কে ই-মেইল পাঠানোর api, বড় ফাইল আপলোড, বিভিন্ন ডাটা সোর্স থেকে ডাটা মাইগ্রেশন ইত্যাদি বিভিন্ন ভারী কাজের api ইমিডিয়েট রেস্পন্স পাঠানোর দরকার নেই, কয়েক সেকেন্ড, মিনিট দেরি হলেও সমস্যা নেই বরং কাজ হয়ে গেলেই হলো ৷ এসব কাজ Queue তে রেখে দিলে ভালো পারফর্ম্যান্স পাওয়া যায় ।</p><p>ধরেন একটা ব্লগ পোস্টের কত ভিউ হইছে, সেটা কি এখনই রেস্পন্স দেয়া খুবই জরুরি?</p><p>৫ মিনিটে ২০ হাজার ভিউ হইছে এই স্কেলের কথা চিন্তা করেন।</p><p>একই ব্লগ পোস্টের জন্য ৫ মিনিটে ডাটাবেজে ২০ হাজার সেপারেট আপডেট অপারেশন কি ভালো হবে নাকি কিউ থেকে মার্জ হয়ে একটা বাল্ক রাইট অপারেশন ডাটাবেজের performance এর জন্য ভালো হবে???</p><p>৫ মিনিট পর পর বাল্ক অপারেশন করলেই তো হলো? তাই-না.</p><p>কয়েক হাজার ইমেইল পাঠানোর জন্য কত সেকেন্ড সময় লাগতে পারে?? এত সময় কি ফ্রন্টেন্ডের রেস্পন্স পাঠানোর জন্য ব্যয় করা খুবই জরুরি??</p><p>একটা ১ জিবির ফাইল আপলোড ব্যাকগ্রাউন্ডে প্রসেস করা ভালো নাহ??</p><p><strong><em>Job Queue</em></strong>. <strong><em>Scheduler Queue</em></strong>, <strong><em>Message Queue</em></strong> কিওয়ার্ড সার্চ দিলেও অনেক তথ্য পেয়ে যাবেন।</p><p><strong><em>Bull</em></strong> নামে একটা নোড ( npm/yarn) প্যাকেজ আছে। একটু ঘেটে দেখতে পারেন।</p><h4>2. PubSub pattern:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gknNMBeyOY9LxzmY.jpeg" /></figure><p>ইভেন্ট ড্রিভেন আর্কিটেকচার নিয়ে আইডিয়া থাকলে ইজিলি বুঝতে পারবেন এর কাজ কি।</p><p>Node এ <em>EventEmitter</em> নামে একটা প্যাকেজ আছে। সিঙ্গেল নোড প্রসেস ইউজ করে কাজ করে। একটা worker এ এমিট হওয়া ইভেন্ট অন্য কোনো ওয়ার্কার access করতে পারে না ।</p><p>সেক্ষেত্রে, রেডিস কে Inter process communication এর জন্য ইউজ করা যেতে পারে ৷</p><p>রেডিস পাব সাব মেসেজিং করতে Redis Process ইউজ করে। রেডিসের ডিবির সাথে এর কোনো সম্পর্ক নেই ।</p><p>গ্রাফকিউএল সাবস্ক্রিপশন এর সাথেও রেডিস পাব সাব কানেক্টে করা যায় |</p><h4>3. Microservices Data Transport :</h4><p>রেডিস পাব সাব ইউজ করে Redis কে ইজিলি মেসেজ ব্রোকার হিসেবে ইউজ করা যায় । রেডিস ফায়ার এন্ড ফরগেট মেথডে কাজ করে ।</p><p><strong><em>Nest.JS</em></strong> নামে একটা টাইপস্ক্রিপ্ট বেজড নোড জেস ফ্রেমওয়ার্ক আছে যার ডকুমেন্টেশনের মাইক্রোসার্ভিস সেকশনে খুব সুন্দর করে রেডিস কে বিভিন্ন সার্ভিসের সাথে কীভাবে কমিউনিকেট করা যায় কিউট এক্সাম্পল সহকারে দেয়া আছে |</p><p>যাই হউক, পাবলিশার ডাটা পাবলিশ করে বাট কোনো সাবস্ক্রাইবার লিসেন করলে ডাটা পাবে । কেউ লিসেন না করলেও রেডিস এমন রিয়েক্ট করে যেন কিছুই হয় নি ।</p><p>গার্লফ্রেন্ড রাগ করে ঝাড়ি দিয়েই যাচ্ছে | কিন্তু আপনি যেন কিছুই শুনেন নি অবস্থা আর কি |</p><p>কোনো সাবস্ক্রাইবার না থাকলে মেসেজ অটো রিমুভ হয়ে যাবে, আর রিকভার করা যাবে না ।</p><p>মেসেজ/ইভেন্ট পাস হলো কিনা, অন্তত একটা মাইক্রো সার্ভিস লিসেন করলো কিনা তার কোনো গ্যারান্টি রেডিস দিতে পারে না ।</p><p>তাই <strong><em>Message Durability and acknowledgement</em></strong> এর জন্য ডেডিকেটেড মেসেজ ব্রোকার যেমন: <strong><em>RabbitMQ</em></strong> টাইপের কিছু ইউজ করা ভালো ।</p><p>স্টিল যেহেতু গরীবের মেসেজ ব্রোকার সেহেতু গরীবানা সুরতে দুয়েকটা কেস পেয়েও যেতে পারেন যেখানে রেডিস ইউজ করলেই চলে</p><p>ভুল ত্রুটি ধরে দিলেই মার্জনীয় ।</p><p>ধন্যবাদ</p><p>( চলবে…)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b733cb4bd3f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[রেডিস কথন ২]]></title>
            <link>https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%A8-66d0f6cb862b?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/66d0f6cb862b</guid>
            <category><![CDATA[rate-limit]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[redis-bangla]]></category>
            <category><![CDATA[redis-usecase]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Tue, 08 Aug 2023 08:36:13 GMT</pubDate>
            <atom:updated>2023-08-08T08:36:13.260Z</atom:updated>
            <content:encoded><![CDATA[<p>মানবজীবনে রেডিসের ভুমিকা</p><p><em>Previous Blog:</em> <a href="https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%A7-3da03a6e94db">#রেডিস_কথন ১</a></p><p>আমরা আজকে রেডিসের ইউজকেস কি, কি ধরনের সমস্যা সমাধানে রেডিস বেশি ব্যবহৃত হয় তা আলোচনা করবো। সিরিজের আগের ব্লগ মিস হয়ে গেলে, কমেন্ট থেকে খুজে নিন…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/0*rSHJEL3uXqufqUPD" /></figure><h4>1. Cache</h4><p>এপ্লিকেশনে অনেক ডাটা খুব কমই আপডেট করতে হয় যেমন: কোম্পানির নাম, লোগো, ক্যাটাগরি সমুহ, এবাউট পেজের ডাটা,পোস্ট, একটা প্রোডাক্টের মুল ইনফরমেশন ইত্যাদি ইত্যাদি ।</p><p>খুব আপডেট হয় কিন্তু অনেক রিড করতে হয় এমন ডাটা ক্যাশ করলে ফাস্টার রেস্পন্স পাওয়া যায় । ধরেন এই পোস্ট/ব্লগ ই আমি এখন লিখছি, বানান ঠিক করতে ধরেই নিলাম কয়েকবার আপডেট করতে হলো ।</p><p>কিন্তু এরপর আর কখনো আপডেট করবো বলে মনে হয় না। রিড কিন্তু ৫/১০ টা করে একবছর পরেও ২/৩ টা ভিজিট হতেই পারে ৷</p><p>একটা ই-কমার্সের প্রডাক্ট এর মুল ইনফরমেশন নাম, সাইজ, কালার,ডিটেলস, ইমেজগুলোর লিংক, ইত্যাদি কিন্তু ডাটাবেজে একবার ক্রিয়েট হয়ে গেলে আর প্রতিদিন আপডেট করতে হয় না ।</p><p>ডিস্ক বেজড স্টোরেজে ডাটা রিড/রাইট করতে তুলনামূলকভাবে মেমরি থেকে বেশি সময় লাগে ।</p><p>অতএব পরবর্তীতে ইউজার ওই ডাটা দেখতে চাইলে মেমরি থেকে দেখালেই ফাস্টার রেস্পন্স হলো</p><p>প্রায় ডাটাবেজ থেকেই রেডিসের লেটেন্সি অনেক কম |</p><p>এছাড়া চাইলেই, ফুল পেজও ক্যাশিং করা যায় ৷</p><p>রেডিস হচ্ছে ক্যাশিং জগতের জন উইক।</p><p>নাম চিনলেই সবাই চেনে এবং বড় ভাই হিসেবে সালাম দেয় ( নো র‍্যাগিং) |</p><h4>2. Session Store:</h4><p>ইউজার এর সেশন স্টোরের জন্য রেডিস খারাপ চয়েজ নাহ ৷ অথেনটিকেশন এ সেশন কি ভেরিফাই এর জন্য ডাটাবেজে যাওয়া লাগলো না বারবার। 95%+ api ই তোহ Auth বেজড</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/16/0*FFJOeyrrDP5L9mf7.png" /></figure><h4>3. Expiration Data:</h4><p>রেডিস Key-value স্টোরেজ । এর যেকোনো Key কে ( TTL — Time To Live) সেট করা যায়। এর অর্থ নির্দিষ্ট সময় পর রেডিস ওই key কে স্টোরেজ থেকেই ডিলিট করে দেয় ।</p><p>OTP কয়েক মিনিট পর ইনভ্যালিডেট হয়ে যায় ।</p><p>Access Token এর মেয়াদ ও অনেক কম হয় । EXPIREAT কমান্ড দিয়ে ঠিক কোন সময় Key ডিলিট করতে হবে সেটাও বলা যায়। User intentionally logout করলে Key কে ডিলিট করলে কিন্তু একই টোকেন আবার ইউজ করা যাবে না</p><h4>4. Rate Limit :</h4><p>লগিন API, Payment API খুবই সেন্সিটিভ API. হ্যাকারের উৎপাতও থাকে অনেক ।</p><p>যেকোনো রিসোর্স কে লিমিটেড এক্সেস দেয়ার জন্য রেট লিমিট ইউজ করা হয় ৷</p><p>ধরেন লগিন API কে মিনিটে ২ বারের বেশি হিট দিতে চাচ্ছেন না কোনো ইউজারকে সেক্ষেত্রে তার আইপি/ডিভাইস ইউনিক আইডেন্টিফায়ার/ব্রাউজার আইডেন্টিফায়ার কে Key হিসেবে ইউজ করে নাম্বার ডাটা টাইপ কে ইনক্রিমেন্ট এন্ড লজিক্যাল কন্ডিশনাল অপারেটর ইউজ করলেই কিন্তু সহজেই ইম্পলিমেন্ট করা যায় রেডিসে ( এই লাইনগুলো বলতে অনেক ফ্যান্সি লাগছে আমার)</p><p>আজ এটুকুই থাক…</p><p>বাকি অংশ আসছে শীঘ্রই….</p><p>মানুষ মাত্রই ম্যাশিন নাহ, এতএব ভুল ত্রুটি ধরে দিলেই মার্জনীয়।</p><p>ধন্যবাদ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66d0f6cb862b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[রেডিস কথন ১]]></title>
            <link>https://samayun.medium.com/%E0%A6%B0%E0%A7%87%E0%A6%A1%E0%A6%BF%E0%A6%B8-%E0%A6%95%E0%A6%A5%E0%A6%A8-%E0%A7%A7-3da03a6e94db?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3da03a6e94db</guid>
            <category><![CDATA[redis-bangla]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[রেডিস]]></category>
            <category><![CDATA[redis-blog]]></category>
            <category><![CDATA[redis-module]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Thu, 18 May 2023 05:06:03 GMT</pubDate>
            <atom:updated>2023-05-18T05:06:03.924Z</atom:updated>
            <content:encoded><![CDATA[<p>রেডিস জিনিসটা কি? রেডিসন নাম কি রেডিস থেকে এসেছে? নাকি যে লেডিস রেড কালার পছন্দ করেন তাকে রেডিস বলা হয়? নাকি অন্যকিছু 🤔</p><p>চিন্তার বিষয় 🤔</p><p>ডেভলপার যেহেতু পোস্ট দিছে সেহেতু এটা টেকনিক্যাল ব্যপার সেপার নিশ্চয়ই । দেখা যাক রেডিস জিনিসটা আসলে কি ।</p><p>কৈ মাছের প্রাণ রেডিস টেক ইন্ডাস্ট্রিতে ব্যবহৃত হচ্ছে বহু বছর ধরে । কিন্তু ইলিশের মতোই অনেক কাটাযুক্ত কিন্তু বড্ড স্বাদ লাগে খেতে একে ৷ স্কিলের বাজারে তাই এর দর-দাম অনেক 😃</p><p>পদ্মা নদী ঘুরা হউক কিন্তু রেডিস ও কিছুটা শেখা হউক। কেমন?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYDmyu0eBSxLQBVr8YwF8Q.png" /></figure><p>Redis এর পুর্নরুপ REmote DIstributed Server.</p><p>এটি একটি ওপেন সোর্স In memory key-value data store. একটি ইতালিয়ান স্টার্টআপ রিয়েল টাইম ওয়েব লগ এনালাইজার বানাতে স্কেলেবিলিটি ইম্প্রভমেন্টের জন্য এটি ডেভলপ করেছিলো।</p><p>মুল ডেভলপার Sanfilippo কে VMWare পরবর্তীতে হায়ার করেছিলো ।</p><p>ইন মেমরি স্টোরেজ হলেও একে ডিস্কে পারসিস্ট করা যায়। ডিফল্ট periodically ২ সেকেন্ড পর পর ডিস্কে স্টোর করা হয় কিংবা প্রত্যেক কমান্ড রান হলেই ব্যাকগ্রাউন্ডে ডিস্কে স্টোর করা যায়। প্রয়োজনে পারসিস্ট অপশন ডিজেবল করা যায়। আমরা জানি, মেইন মেমরি সেকেন্ডারি মেমরির চেয়ে ফাস্টার রেসপন্স করে ৷</p><p>অতএব, রেডিস যেহেতু ডাটা আগে মেমরিতে স্টোর করে অতএব সে উসাইন বোল্টের মতোই গতি দানব ( গদা 😉) ৷</p><p>এজন্য রেডিস ক্যাশিং এর জন্য বেশি ব্যবহৃত হয় ।</p><p>রেডিসে অনেক ধরনের ডাটা স্ট্রাকচার রয়েছে, যেমন: String, Hash, Set, List,Sorted Set, Stream, GeoHash, HyperLogLog . নাম দেখেই বুঝা যাচ্ছে এদের কি কাজ ।</p><p>না বুঝলেও প্যারা নাই। পরবর্তী ব্লগে একেক ডাটা স্ট্রাকচার কেন এবং কীভাবে ব্যবহার করা যায় সে নিয়ে বিস্তারিত লেখার চেষ্টা করবো ☺️☺️</p><p>একটু চিন্তা করেন, ডিস্কে স্টোর করা যায় এবং এরকম পাওয়ারফুল ডাটা স্ট্রাকচার সাপোর্ট করে সেহেতু একে কি ডাটাবেজ হিসেবে ব্যবহার করতে পারা উচিত নয় কি? হ্যা, Redis Enterprise ইউজ করলে আপনি রেডিস কে একদম MongoDB, MySQL এর মতোই প্রাইমারি ডাটাবেইজ হিসেবে ব্যবহার করতে পারবেন ৷ কোন ধরনের এপ্লিকেশনে রেডিসকে প্রাইমারি ডাটাবেইজ হিসেবে ব্যবহার করা উচিত সেটা বিশ্লেষণযোগ্য এবং এপ্লিকেশন টাইপ, ফিচার, ইউজকেস অনেক কিছুই ম্যাটার করে ।</p><p>এতোটুকু জানা প্রয়োজন, Redis এর অনেক ধরনের মডিউল রয়েছে যেমন:</p><p>১. RedisJSON: রেডিস ডিরেক্টলি json document store and query করতে সক্ষম । এ মডিউল ইউজ করলে String data structure ইউজ করতে একটা ফিল্ড আপডেটের জন্য আগের কি রিমুভ/ফরগেট করা নতুন key আপডেট করা, serialize, deserializing মতো কাজ আর কর‍তে হয় না । ডিরেক্টলি json ডাটা রিড/রাইট করা যায়। সহজেই বিভিন্ন মডেলের ডাটা ইউজ করা যায় 🫠</p><p>২. RedisSearch: ইন্ডেক্সিং, ফুলটেক্সট সার্চ,এগ্রিগেশন কুয়েরী করতে এ মডিউল ব্যবহার করা যায় ৷ ElasticSearch, MongoDB Atlas Search এর সাপেক্ষে তুলনা না করি কিন্তু এপ্লিকেশনে ছোট একটা পার্টে রিয়েল টাইম সার্চিং প্রয়োজন হলে এর ভালোই ইউজকেস আছে বলা যায়। রিয়েল টাইম লোকেশন সার্চ ও করা সম্ভব 😄</p><p>৩. RedisGraph: গরীবের গ্রাফ ডাটাবেজ 😅</p><p>৪. RedisTimeSeries: IoT ডিভাইসে টাইম সিরিজ ডাটা নিয়ে কাজ করা প্রয়োজন হয় প্রায় ই, সো চেক ইট আউট ইফ ইউ নিড ৷</p><p>৫. RedisBloom: probabilistic data structures নিয়ে কাজ করতে এ মডিউল ইউজ করা হয় ৷ Bloom filter and Cuckoo filter, Count-min sketch, TopK ইত্যাদি নিয়ে কাজ করা যায়৷ — — — -</p><p>৬. Redis Cell: rate limiting এর জন্য ব্যবহৃত হয়।</p><p>৭. RedLock: Distributed Lock system</p><p>. ৮. Lqrm: Laravel Queue Redis Module</p><p>৯. Redis-protobuf: Redis module for reading and writing protobuf messages</p><p>১০. Session Gate: a module for session management by Redis.</p><p>১১. RedisAI:</p><p>১২. Neural-redis: Neural networks module for Redis</p><p>বুঝাই যাচ্ছে Redis key-value storage ই নয় শুধু এর ইউজকেস অনেক ৷ এখন রেডিস অনেক ধরনের ডাটা মডেলিং সাপোর্ট করে ।</p><p>অতএব এর ডাটা স্ট্রাকচার নিয়ে এক বা একাধিক ব্লগ এবং শুধুমাত্র ইউজকেস নিয়ে একটি ব্লগ লিখা হবে এ রেডিস কথন সিরিজ এ ৷ ভুল ত্রুটি ধরিয়ে দিন, নলেজ শেয়ারিং এ অংশ নিন। সাথে থাকার জন্য, ধন্যবাদ ।</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3da03a6e94db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup CI/CD for typescript based npm package]]></title>
            <link>https://samayun.medium.com/setup-ci-cd-for-typescript-based-npm-package-3f3c6354b143?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f3c6354b143</guid>
            <category><![CDATA[npm-package]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[typescript-package]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 19:28:04 GMT</pubDate>
            <atom:updated>2022-10-09T17:51:43.641Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setup CI/CD for typescript based npm package publishing</h3><p>Hi Coder .<br>I’m Samayun Chowdhury .<br>I am a learner &amp; love explore new things. I am building some open source npm package…</p><p>I have to setup many individual repositories for separated packages. (monorepo would be a sexy solutions I know but my purpose is different )</p><p>I think re-setup each packages’s scripting, linting, testing, publishing to npm registry is so boring &amp; time greedy.</p><p>To respect myself as a lazy developer. I like to write code using intellisense &amp; push to code repository.</p><p>I don’t like to update version on package.json , tag this version then login to npm, re-type OTP verification code after chacking email, then write another command npm publish then you have successfully upgraded a version.</p><p>When you are fixing bugs &amp; implementing features continously . Isn’t it so boring manually versioning and publish to npm registry?</p><p>I think so . I took decision to automate this setup for forever.</p><blockquote><em>&quot; </em><strong><em>When you see something that is needed you either find it or you create it </em></strong><em>&quot;</em></blockquote><blockquote><strong>- JOHN SONMEZ</strong></blockquote><blockquote><em>(Author of `Soft Skills: The Software Developer&#39;s Life Manual`)</em></blockquote><p>I found it so I’m implementing it and sharing with you. Sharing is caring :) <br>I followed this video content : <a href="https://www.youtube.com/watch?v=QZdY4XYbqLI&amp;ab_channel=BrunoAntunes"><em>YouTube Content</em></a><em> .</em></p><p>I am still writing this article because of frustration . A whole night I was nightmare for me.</p><p>CI wasn’t working properly for some silly mistakes.</p><p>If you follow this video tutorial and your CI/CD pipeline working properly . that’s fine you can skip this article from here.</p><p>Otherwise if you like articles before video content or pipeline doesn’t work properly then please continue exploring from here.</p><p><strong>Step by Step</strong>:<br> * Bootstrap using<strong><em> </em></strong><em>TSDX</em><br> * Environment Setup for CI/CD<br> * Semantic Versioning<br> * Setup GitHub Actions</p><h4>Bootstrap using <em>TSDX</em></h4><p>npx tsdx create my-package</p><h4>Environment Setup for CI</h4><p>Setup secrets first GH_TOKEN is a PAT token of GitHub . It will be used for release tag versions via CI . and NPM_TOKEN is for NPM registry package publish/write access .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94EINzfFsLHVRFqClHAVbA.png" /></figure><p><strong>Setup Semantic Versioning</strong></p><p><strong>Setup GitHub Actions</strong></p><p>.github/workflow/publish.yml</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f3c6354b143" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s burn your code by fire ]]></title>
            <link>https://samayun.medium.com/lets-burn-your-code-by-fire-dffb383e0634?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dffb383e0634</guid>
            <category><![CDATA[fire-code]]></category>
            <category><![CDATA[power-mode]]></category>
            <category><![CDATA[fire-effect-vscode]]></category>
            <category><![CDATA[fireeffect]]></category>
            <category><![CDATA[burn-code]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 10:16:52 GMT</pubDate>
            <atom:updated>2022-01-18T10:49:00.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>Let’s burn your code by fire</h3><blockquote>A lots of frustation in coding life, so burn your code and feel stres less ;)</blockquote><p>Hi coder’s . Hope you are well.</p><p>If not well, don’t worry after reading this blog you will be FIREMAN. your code will be fired :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*CTtnya8LSqT-fylfG9b2dw.gif" /></figure><p>No more talk just read &amp; implement.</p><p>Open your vscode &amp; search “Power Mode” on extension search bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*D4tTsesEbqvfm3v4Ajsy1A.png" /></figure><p>Install this &amp; configure it like this.</p><pre>Go to <strong>settings</strong> &gt; <strong>workspace</strong> &gt; <strong>extensions</strong> &gt; <strong>Power Mode</strong> -&gt; Powermode: <strong>Presets</strong> -&gt; Select whatever you like (use <strong>Flames</strong> for fire effect )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*KMOC4GgZQqFhC1a0gfGDlA.png" /></figure><p>You can do it using vscode config too:</p><p>open your workspace</p><p>create a file settings.json inside .vscode directory</p><pre>// .vscode/settings.json</pre><pre>{<br>  &quot;powermode.enabled&quot;: true,</pre><pre>  &quot;powermode.presets&quot;: &quot;flames&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*CTtnya8LSqT-fylfG9b2dw.gif" /></figure><p>Let’s enjoy it</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dffb383e0634" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most productive exception handling ever on Node.js]]></title>
            <link>https://samayun.medium.com/most-productive-exception-handling-ever-on-node-js-96828aac83cf?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/96828aac83cf</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[productive-tips]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[exception-handling]]></category>
            <category><![CDATA[productive]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Mon, 13 Dec 2021 13:54:45 GMT</pubDate>
            <atom:updated>2021-12-15T07:52:00.399Z</atom:updated>
            <content:encoded><![CDATA[<h4>Redirect to StackOverflow when get exceptions to find solution of error messages</h4><pre>const url = `http://stackoverflow.com/search?q=[js]&#39;${error.message}&#39;`;</pre><pre>require(‘child_process’).exec(`firefox ${url}`)</pre><figure><img alt="Most productive exception handling ever on Node.js" src="https://cdn-images-1.medium.com/max/1024/1*kJohPupZ3SRYVaA0Pxi-EA.png" /></figure><pre>// Most productive exception handling ever on Node.js</pre><pre>const url = `<a href="http://stackoverflow.com/search?q=[js]&#39;${error.message}&#39;%60">http://stackoverflow.com/search?q=[js]&#39;${error.message}&#39;`</a>;<br>// firefox on linux<br>require(&#39;child_process&#39;).exec(`firefox ${url}`);<br>// chrome on linux<br>require(&#39;child_process&#39;).exec(`google-chrome --no-sandbox ${url}`);<br>// chrome on MacOSX<br>require(&#39;child_process&#39;).exec(`open -a &quot;Google Chrome&quot; ${url}`);<br>// microsoft-edge on Windows<br>require(&#39;child_process&#39;).exec(`start microsoft-edge:${url}`);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96828aac83cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Array to Hashmap in Node.js application]]></title>
            <link>https://samayun.medium.com/array-to-hashmap-in-node-js-application-36862cb8746c?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/36862cb8746c</guid>
            <category><![CDATA[hashmap]]></category>
            <category><![CDATA[array-to-hashmap]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[hashmap-javascript]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Sat, 19 Jun 2021 14:25:46 GMT</pubDate>
            <atom:updated>2021-06-19T14:40:45.444Z</atom:updated>
            <content:encoded><![CDATA[<h3>Array to Hashmap in Express application</h3><p>এই আমি সামায়ুন, <br> এই আমার ফ্রেমওয়ার্ক ( <a href="https://github.com/samayun/express-mvc-rest-boilerplate">https://github.com/samayun/express-mvc-rest-boilerplate</a> )<br> এবার পার্টি হবে যে 😉<br> <br> ব্যক্তিগত কারণে এরে ডাটা স্ট্রাকচারে কে ডিভোর্স দিয়ে হ্যাশম্যাপ ব্যবহার করতে যাচ্ছি ।<br> আপনিও গাড়িসহ আমার সাথে আত্মগোপনে যেতে চলে আসুন আমার রিপোজিটরি তে 😉</p><figure><img alt="Hashmap in Javascript" src="https://cdn-images-1.medium.com/max/879/1*cQXeEylLI1nkjT6H65Yiaw.png" /><figcaption>Image : Hashmap in JavaScript</figcaption></figure><p>This is the the code to change any array to hashmap . use a key String or Function type parameter in toHashMap(&#39;_id&#39;) method</p><h3><strong>Convert array to hashmap</strong></h3><pre>// ./utils/Array.hashmap.js</pre><pre>function isFunction(func) {</pre><pre>  return Object.prototype.toString.call(func) === &#39;[object Function]&#39;;</pre><pre>}</pre><pre>Array.prototype.toHashMap = function (key) {<br>var _hashMap = {}, getKey = isFunction(key) ? key : function (_obj) { return _obj[key]; };</pre><pre> var _hashMap = {}, getKey = isFunction(key) ? key : function (_obj) { return _obj[key]; };</pre><pre> this.forEach(function (obj) {</pre><pre>   _hashMap[getKey(obj)] = obj._doc;</pre><pre>});</pre><pre>return _hashMap;</pre><pre>};</pre><pre>module.exports = Array;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ZWAKWe1yOxtHoi1GHWNHQ.png" /></figure><h4><strong>Our previous style code</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGHxsQvDxzRlmXCUsIcqPQ.png" /></figure><h4><strong>Our previous style response</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*Q1KnE50OZNHwgb3OwkmQzg.png" /><figcaption>Previous output for our array based response</figcaption></figure><h4><strong>New style Code</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ZWAKWe1yOxtHoi1GHWNHQ.png" /></figure><h4><strong>Hashmapped response</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*m0vY8lwj-X4EjwNPV3GCdg.png" /><figcaption>Current response version converted into hashmap</figcaption></figure><p>Thank You</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36862cb8746c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Install Avro Keyboard in Linux Mint]]></title>
            <link>https://samayun.medium.com/install-avro-keyboard-in-linux-mint-c88be1239d85?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c88be1239d85</guid>
            <category><![CDATA[avro-linux]]></category>
            <category><![CDATA[avro-keyboard-linux]]></category>
            <category><![CDATA[avro-linuxmint]]></category>
            <category><![CDATA[avro-ibus]]></category>
            <category><![CDATA[avro]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Fri, 11 Jun 2021 17:11:36 GMT</pubDate>
            <atom:updated>2021-06-11T17:11:36.671Z</atom:updated>
            <content:encoded><![CDATA[<p>On Ubuntu, and on Debian’s <em>testing</em> and <em>unstable</em> releases, Avro phonetic is distributed through the ibus-avro package. To install it, simply do:</p><pre>sudo apt-get install ibus-avro</pre><p>On other Linux distros you can install the dependencies and build/install using the source code in this repository.</p><p>Open terminal/package manager and install following packages:</p><ul><li>git libibus-1.0-dev automake autoconf make gjs ibus</li></ul><p><strong>For e.g. Debian 10 “buster”</strong></p><p>As root, do:</p><p>apt install git libibus-1.0-dev automake autoconf make gjs ibus</p><p><strong>For other linux distributions</strong></p><p>You’ll need all related build tools like automake, autoconf etc... and to run it you need ibus and gjs. Use the list of packages above as guidance, but please note that some packages may have other names.</p><p>Now give the following commands step-by-step:</p><ul><li>git clone git://github.com/sarim/ibus-avro.git cd ibus-avro aclocal &amp;&amp; autoconf &amp;&amp; automake --add-missing ./configure --prefix=/usr sudo make install</li></ul><h3>Usage</h3><ol><li>Run <strong>IBus</strong> (Applications -&gt; System Tools -&gt; IBus) from <em>Dash</em></li><li>Open <strong>IBus</strong> Preferences from the top panel icon</li><li>Go to Input method</li><li>Select an input method -&gt; Bengali -&gt; Avro</li><li>Now Click Add button to add <strong>Avro</strong> to the list</li><li>Now restart <strong>IBus</strong> from the top panel icon (Right Click -&gt; Restart)</li><li>Now Press Ctrl+Space to toggle between <em>English</em> and <em>Avro</em> (Bengali)</li><li>Enjoy <strong>Avro Phonetic!</strong></li></ol><p>apt install git libibus-1.0-dev automake autoconf make gjs ibus</p><p>Any problem</p><p>$HOME:./bashrc</p><p>export GTK_IM_MODULE=ibus<br> export XMODIFIERS=<a href="http://twitter.com/m">@m</a>=ibus<br> export QT_IM_MODULE=ibus</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c88be1239d85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript The Tricky Parts: Part-2]]></title>
            <link>https://samayun.medium.com/javascript-the-tricky-parts-part-2-1cf32a8dd825?source=rss-39ef8cdf061a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf32a8dd825</guid>
            <category><![CDATA[advanced-javascript]]></category>
            <category><![CDATA[javascript-interview]]></category>
            <category><![CDATA[javascript-tricks]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Samayun Miah Chowdhury]]></dc:creator>
            <pubDate>Sat, 08 May 2021 13:32:58 GMT</pubDate>
            <atom:updated>2021-05-08T15:12:24.888Z</atom:updated>
            <content:encoded><![CDATA[<h3>JavaScript The Tricky Parts🙄: Part-2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*1MRoBnT388OcTWy--FDEKQ.jpeg" /></figure><p>Hey Programmers What are you doing now ?</p><p>Did you read first sequel <a href="https://samayunmc.medium.com/javascript-the-tricky-parts-part-1-1a7c0521fb79"><strong>JavaScript The Tricky Parts: Part-1</strong></a> .If no , please read it first &amp; continue from here.</p><p>Hey , I am Samayun Chowdhury speaking here to make your coding life easier, smarter &amp; comfortable. I will talk about most critical parts of javascript in this series . So don’t waste time . Take a glass of coffee &amp; read my blog .</p><p>Here I am covering 10 tricky topics of javascript .</p><h3>⚔️ Truthy &amp; Falsy Value</h3><p>Truthy &amp; Falsy values are coerced to Booleans when in statements. You can use these statemenst in condition block in switch, if-else,while blocks. You will see this future more &amp; more . So just read now for easier future 😎</p><p>‘’ or “” (Empty String) , false , 0 , NaN, undefined, null are falsy values .</p><p>&amp; rest are truthy values . These are false too 😳</p><p>console.log({} == {}) console.log([] == [])</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*ra3UU1AcHgR0cGey.jpeg" /></figure><h3>⚔️<strong> Equality Check Operator</strong></h3><p>There has two kinds of quality check operator Loose &amp; Strict Equality Opearator. == check operands value &amp; apply automatically coercion ,it doesn’t check operands type .</p><p>strict equality === operator checks operands value &amp; type . Doesn’t apply coercion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*rsNKv31e_VlyYTOGRh7ynQ.png" /></figure><pre>// loose equality vs strict equality<br>&quot;55&quot; == 55   // -&gt; true<br>&quot;55&quot; === 55  // -&gt; false</pre><pre>console.log(&quot;2&quot; == 2) // true<br>console.log (&quot;2.04&quot; == 2.04) // true<br>console.log(true == 1) //true<br>console.log(&quot;0&quot; == false) //true</pre><pre>console.log(2 === 2) // true<br>console.log(&quot;Hello&quot; === &quot;Hello&quot;) // true<br>console.log (&quot;2.04&quot; === 2.04) // false<br>console.log(true === 1) //false</pre><h3>⚔️ Global &amp; Local Scope</h3><p>Scope determines the accessibility (visibility) of variables.</p><p>JavaScript Function Scope</p><p>In JavaScript there are two types of scope:</p><ul><li>Local scope</li><li>Global scope</li></ul><p>JavaScript has function scope: Each function creates a new scope.</p><p>Scope determines the accessibility (visibility) of these variables.</p><p>Variables defined inside a function are not accessible (visible) from outside the function.</p><h4>Local JavaScript Variables</h4><p>Variables declared within a JavaScript function, become <strong>LOCAL</strong> to the function.</p><p>Local variables have <strong>Function scope</strong>: They can only be accessed from within the function.</p><pre>// code here can NOT use carName<br><br>function getCarname() {<br>   var carName = &quot;Lamborgini&quot;;<br>   <br> // code here (inside function) CAN use carName<br>}</pre><pre>// code here can NOT use carName</pre><p>Since local variables are only recognized inside their functions, variables with the same name can be used in different functions.</p><p>Local variables are created when a function starts, and deleted when the function is completed.</p><h4>Global JavaScript Variables</h4><p>A variable declared outside a function, becomes <strong>GLOBAL</strong>.</p><p>A global variable has <strong>global scope</strong>: All scripts and functions on a web page can access it.</p><h4>Automatically Global Variable</h4><p>If you assign a value to a variable that has not been declared, it will automatically become a <strong>GLOBAL</strong> variable.</p><p>This code example will declare a global variable carName, even if the value is assigned inside a function.</p><pre>myFunction();<br><br>// code here can use carName  <br><br>function myFunction() {<br>     carName = &quot;Volvo&quot;;<br>}</pre><h4>Strict Mode</h4><p>in mid level project if someone creates global variable may conflict with others code , which can be reason for some unexpected errors . Stop automatically creating global variables by using &#39;use strict&#39; line in the top of code blocks.</p><h3>⚔️ Closure, encapsulation, private variable</h3><p>JavaScript variables can belong to the <strong>local</strong> or <strong>global</strong> scope.</p><p>Global variables can be made local (private) with <strong>closures </strong>👁‍ .</p><p><strong>Variable Lifetime</strong></p><p>Global variables live until the page is discarded, like when you navigate to another page or close the window.</p><p>Local variables have short lives. They are created when the function is invoked, and deleted when the function is finished.</p><pre>const add = (function(){<br>  var counter = 0;<br>  return function(){<br>    counter += 1;<br>   return counter;<br>  }<br>})();</pre><pre>console.log(add());<br>console.log(add());</pre><p>A function returns another function means Closure .</p><p>Hiding some variables or making them private or make global variables hidden(private) is called encapsulation .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*5Hprm375H74hdAXx.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf32a8dd825" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>