A cache is a reserved storage location that collects temporary data to help websites, browsers, and apps load faster. The data stored in a cache might be the result of an earlier computation or a copy of data stored elsewhere.

A cache hit occurs when the requested data can be found in a cache, while a cache miss occurs when it cannot.

Types of Cache

Redis is an in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. …


While working with data or replicating data sources, you probably have heard the term Change Data Capture (CDC). As the name suggests, “CDC” is a design pattern that continuously identifies and captures incremental changes to data. This pattern is used for real-time data replication across live databases to analytical data sources or read replicas. It can also be used to trigger events based on data changes, such as the OutBox pattern.

Most modern databases support CDC through transaction logs. …


When it comes to concurrency, both CountDownLatch and CyclicBarrier are used for managing multi-threaded applications.

And, they are both intended to express how a given thread or group of threads should wait.

CountDownLatch

A CountDownLatch is a construct that a thread waits on while other threads count down on the latch until it reaches zero.

We can think of this like a dish at a restaurant that is being prepared. No matter which cook prepares however many of the n items, the waiter must wait until all the items are on the plate. …


Problem statement

TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk.

Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You just need to ensure that a URL can be encoded to a tiny URL and the tiny URL can be decoded to the original URL.

Solution

1. Write a simple solution using hashcode for longUrl stored in a Map to encode and decode from longUrl to shortUrl and vice-versa.

public class Codec {

Map<String, String> longToShort = new HashMap<>();
Map<String, String> shortToLong = new HashMap<>();

String tinyUrlBase = “http://tinyurl.com/";
// Encodes a URL to a shortened URL. …

1. Functional Requirements

Url Shortener is a service that creates a short alias URL for a corresponding long URL. So, now whenever the user visits the short URL, she will be redirected to the original URL.

URL shortening services like bit.ly or TinyURL are very popular to generate shorter aliases for long URLs. You need to design this kind of web service where if a user gives a long URL then the service returns a short URL and if the user gives a short URL then it returns the original long URL. For example, shortening the given URL through bit.ly :

Example: Let…


Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object.

The Technical Rundown

All Java errors implement the java.lang.Throwable interface, or are extended from another inherited class therein. The full exception hierarchy of this error is:

WHEN CAN IT OCCUR

1. When you serialize an inner class instance

java.io.NotSerializableException can occur when you serialize an inner class instance because:

serializing such an inner class instance will result…


Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object.

There are some cases of Serialization with respect to inheritance :

  1. Case 1: If superclass is serializable then subclass is automatically serializable : If superclass is Serializable, then by default every subclass is serializable. Hence, even though subclass doesn’t implement Serializable interface( and if it’s superclass implements Serializable), then we can serialize subclass object.

// Java program to…


The quality of family relationships is rapidly deteriorating. We love our parents, and they also love us. But sometimes there are things and people we come to love more.

Have you ever observed that parents complaining about their toddler or teen is viewed as normal wherein they will even get sympathetic sighs, but the same about an adult kid will get terribly awkward for the listener? This is because families are supposed to be generally happy, especially if there are adults involved. …


Contains Duplicate |||

Problem Statement
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference between i and j is at most k.

Example 1:
Input: nums = [1,2,3,1], k = 3, t = 0
Output: true
Example 2:
Input: nums = [1,0,1,1], k = 1, t = 2
Output: true
Example 3:
Input: nums = [1,5,9,1,5,9], k = 2, t = 3
Output: false

Basic Idea
Two requirements
The absolute difference between nums[i] and nums[j] is at most…

Sunaina Goyal

Developer, melomaniac, philospher, tea lover

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store