Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created February 1, 2024 15:01
Show Gist options
  • Save halitbatur/02a95934761f14b3ab4f6f0474964b87 to your computer and use it in GitHub Desktop.
Save halitbatur/02a95934761f14b3ab4f6f0474964b87 to your computer and use it in GitHub Desktop.
Cron and Redis

Redis, Websockets and cron Discussion

Write your answers in the comment section below:

  • What is Redis? Mention one use case of Redis.
  • What type of database is Redis and where does it hold its data?
  • What is Websocket and what is it used for?
  • Explain 3 use cases for CRON jobs.
  • What are the 3 types of design patterns in Nodejs?
@FarahArar
Copy link

Farah , Dana , Hala , Mohammad

Q1: Redis is a fast and versatile tool that stores data in memory. It's commonly used for caching, which means storing frequently accessed data in a quick-access location. For example, an e-commerce website can use Redis to store product information or user sessions, making the website faster and more responsive.

Q2: Redis is an in-memory data structure store that can be classified as a NoSQL database. It holds its data primarily in the main memory (RAM) of the server where it is running. However, Redis also provides options to persist data to disk periodically, ensuring durability even in the event of server restarts.

Q3: WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection. It enables real-time, event-driven communication between a client and a server.
Unlike traditional HTTP, which follows a request-response model, WebSockets allow bi-directional communication. This means that the client and the server can send data to each other anytime without continuous polling.

What it’s used for:

  • Chat applications
  • Developing real-time web applications
  • Gaming applications

Q4: Schedule regular backups of your database to prevent data loss.
Log Rotation:

Use CRON to rotate and archive log files, optimizing storage.
Data Synchronization:

Periodically synchronize data from external sources to keep your application up-to-date.

Q5: There are three types of design patterns: Creational — the creation of the object instances. Structural — the way the objects are designed. Behavioral — how objects interact with each other.

@Hadeel-Ali-Obaid
Copy link

Aya, Lina, Mohammad, Hadeel

Q1.an in-memory remote database that offers high performance, replication,
and a unique data model to produce a platform for solving problems.
with use cases such as: profile caching, session storage, redis for leaderboard and redis shopping cart

Q2. Redis is an in-memory key-value store that holds its data primarily in RAM, allowing for high-speed access and low-latency operations.
It is classified as a NoSQL database because it does not rely on the traditional relational database management system (RDBMS) model.

Q3. : WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection. WebSocket is commonly used in web applications for real-time features such as chat applications, online gaming, live updates, collaborative editing, and financial trading platforms.

Q4. Automation: Schedule routine tasks like backups, data synchronization, or system maintenance.
Reporting and Notifications: Generate periodic reports, send alerts based on system metrics, or monitor log files.
Batch Processing: Perform batch jobs such as data imports/exports, image processing, or ETL pipelines at regular intervals.

Q5. Design patterns are a way for you to structure your solution's code in a way
that allows you to gain some kind of benefit, such as faster development speed and code reusability.
types of design patterns:
Creational - the creation of the object instances.
Structural - the way the objects are designed.
Behavioural - how objects interact with each other.

@MsDiala
Copy link

MsDiala commented Feb 1, 2024

Diala / Renad / Ahmad / Hassan

1- Redis:

  • In-memory data store used for caching, message brokering, and as a database.
  • Use Case: Enhancing web application performance by caching frequently accessed data.

2- Redis Database Type:

  • An in-memory key-value store.
  • Data is primarily held in memory with optional disk persistence.

3- Websocket:

  • A protocol for full-duplex communication over a single TCP connection.
  • Used for real-time communication in web applications.

4- CRON Job Use Cases:

  • Automating data backups.
  • Scheduling system maintenance tasks.
  • Generating regular reports.

5- Nodejs Design Patterns:

  • Singleton Pattern: Ensures only one instance of a class.
  • Factory Pattern: Creates objects without specifying the exact class.
  • Observer Pattern: Allows objects to subscribe to and react to events.

@sarajouma
Copy link

Sara jouma, Ahmad Mash, Mohammad Abdullah ,Nour kayyali

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

Redis can be used to store metadata about users' profiles and viewing histories, authentication information/tokens for millions of users, and manifest files to enable CDNs to stream videos to millions of mobile and desktop users at a time.

Q2: Redis is a NoSQL database and falls under the category of key-value stores. It holds data on physical disk as a binary file called dump. rdb

Q3: WebSockets are used for real-time, event-driven communication between clients and servers. They are particularly useful for building applications requiring instant updates, such as real-time chat, messaging, and multiplayer games.

Q4:

  • Data Backups: Regularly back up databases or important files.
  • Scheduled Jobs: Execute scripts for updating cached data, sending notifications, or processing data.
  • Reports: Generate and send reports at specific times.

Q5:

  1. Creational Patterns: These patterns focus on object creation mechanisms, aiming to improve flexibility, reusability, and maintainability.

  2. Structural Patterns: These patterns deal with how objects are composed and relate to each other, aiming to improve flexibility and maintainability.

  3. Behavioral Patterns: These patterns focus on how objects communicate and collaborate, aiming to improve flexibility and decoupling.

@Hayder000
Copy link

Team 10. Teammates: Hayder Abu Al-Hummos, Lunar Salameh, Wajd Kayyali, Rama Alzeer
A1: Redis ( REmote DIctionary Server) is an open source, in-memory, NoSQL key/value store that is used primarily as an application cache or quick-response database. Because it stores data in memory, rather than on a disk . It is often used for caching mechanism due to it's high performance. Redis can be used for streaming services, and it stores metadata about users' profiles and viewing histories, authentication information/tokens.

A2: Redis is a non-relational database, and it holds it data completely in memory.

A3: WebSocket is a computer communications protocol, providing simultaneous two-way communication channels over a single Transmission Control Protocol (TCP) connection. real-time, event-driven communication between clients and servers. They are particularly useful for building applications requiring instant updates, such as real-time chat, and messaging.

A4:

  1. Scheduled backups or data synchronization between different systems.
  2. Regular system maintenance tasks like log rotation or database cleanup.
  3. Automated scaling of resources based on time-specific requirements.

A5:

  1. Creational: These patterns are designed for class instantiation. They can be either class-creation patterns or object-creational patterns.
  2. Structural: These patterns are designed with regard to a class's structure and composition. The main goal of most of these patterns is to increase the functionality of the class(es) involved, without changing much of its composition.
  3. Behavioral: These patterns are designed depending on how one class communicates with others.

@Karbejha
Copy link

Karbejha commented Feb 1, 2024

Team members : Mohamad Karbejha - Feda - Hammam - Farah

1-What is Redis? Mention one use case of Redis.

Redis is an open-source, in-memory data store known for its speed and flexibility. It's not a traditional database, but rather a data structure server that uses RAM to store data, making it significantly faster than disk-based databases like MySQL or PostgreSQL. This speed advantage makes it ideal for a variety of use cases, with one of the most popular being caching.
Ex: Messaging and queues: Real-time chat applications, task queues, and event processing pipelines can all benefit from Redis's speed and reliability.

2-What type of database is Redis and where does it hold its data?
Redis actually isn't a traditional database in the typical sense. It's categorized as a NoSQL, in-memory data store

3-What is Websocket and what is it used for?
Websocket is a communication protocol that enables real-time, two-way communication between a client (like your web browser) and a server , like Stock tickers and news alerts: Updates are pushed instantly, keeping users informed in real-time.
For example :
https://kur.doviz.com/serbest-piyasa/amerikan-dolari

4- Explain 3 use cases for CRON jobs.
The cron command-line utility is a job scheduler on Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs
1-Automated Backups
2-Scheduled Data Processing
3-System Maintenance Tasks

5-What are the 3 types of design patterns in Nodejs?
There are three types of design patterns: Creational - the creation of the object instances. Structural - the way the objects are designed. Behavioural - how objects interact with each other.

@MohamadSheikhAlshabab
Copy link

room 5 : mohamad, baraa,ahjmad, mahmoud

q1 -What is Redis? Mention one use case of Redis.

  • Redis (which stands for Remote Dictionary Server) is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. It supports various data structures such as strings, hashes, lists, sets, sorted sets, bitmaps, hyperloglogs, and geospatial indexes with radius queries.

  • By using Redis as a caching layer, the web application can store frequently accessed data in memory, which is much faster than accessing data from a database.


q2 - What type of database is Redis and where does it hold its data?

  • Redis is a NoSQL database that stores data in memory. It is a key-value store, which means that it uses a simple key-value pair to store data.

q3 - What is Websocket and what is it used for?

  • WebSocket is a protocol that enables real-time, bidirectional communication between a web client (such as a web browser) and a server.

  • It is a persistent connection that allows the client and server to send and receive data asynchronously without the need for constant polling or long-polling.

  • WebSocket is used for a variety of applications that require real-time communication, such as:

    _**- 1 - Chat applications

    • 2- Real-time analytics
    • 3- Multiplayer games
    • 4- Collaborative editing
    • 5- Notifications**_

q4 - Explain 3 use cases for CRON jobs.

  • CRON jobs are a powerful tool for automating repetitive tasks in a Unix-like operating system.
  • Here are three use cases for CRON jobs:
    **_- 1 - Database maintenance
    • 2 - Content updates
    • 3 - System monitoring_**

q5 - What are the 3 types of design patterns in Nodejs?
**- 1 - Observer Pattern: **

  • This pattern involves a subject (or observable) that maintains a list of its dependents (or observers) and notifies them automatically of any state changes.
  • This pattern is commonly used in Node.js for event-driven programming.

** - 2 - Singleton Pattern: **

  • This pattern ensures that a class has only one instance and provides a global point of access to that instance.
  • This pattern is commonly used in Node.js for creating shared resources, such as a database connection or a logging utility.

- 3 - Module Pattern:

  • This pattern involves creating a module by encapsulating related functions and variables within a single object.
  • This pattern promotes code organization and reusability.

@MonaAlHajEid
Copy link

Team members: Muna Al Haj Eid, Hakimah Ismail, Gorgees Odisho, Raneem Hamrneh.

  1. Redis is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. It is known for its speed, scalability, and flexibility. Redis is an ideal choice for real-time analytics use cases such as social media analytics, ad targeting, personalization, and IoT.
  2. Redis is NoSQL database because it does not use the traditional tabular structure of relational databases like SQL and it holds its data primarily in-memory.
  3. WebSocket is a communication protocol that provides full-duplex communication channels over a single, long-lived connection between a client and a server. It enables real-time, two-way communication between web clients (such as browsers) and servers.
  4. CRON jobs are automated tasks that run on a Unix-like operating system at specified intervals. Here are three use cases for CRON jobs:
  • Automated backups: CRON jobs can be used to schedule automated backups of important files, databases, and directories. This ensures that data is backed up regularly and can be easily restored in case of data loss or corruption.
  • Scheduled maintenance: CRON jobs can be used to schedule routine maintenance tasks such as software updates, security patches, and system scans. This helps keep the system up-to-date and secure.
  • Automated reports: CRON jobs can be used to generate and send automated reports to stakeholders at regular intervals. For example, a CRON job can be used to generate a daily report of website traffic, sales, or other key metrics and email it to the relevant stakeholders.
  1. The Factory pattern:
    Factory >>> decoupling object creation and implementation

a mechanism to enforce encapsulation
building a simple code profiler
builder >>> implementing url obj builder
revealing constructor>>>
Image20240201183601

  • The Revealing Constructor pattern,
    function Person(name, age) {
    this.name = name;
    this.age = age;
    }

Person.prototype = (function() {
function sayName() {
console.log(this.name);
}

function sayAge() {
console.log(this.age);
}

return {
sayName: sayName,
sayAge: sayAge
};
})();

var person = new Person("John", 30);
person.sayName(); // Output: "John"
person.sayAge(); // Output: 30

  • The Builder pattern.
  • mmm

a way for you to structure your solution's code in a way that allows you to gain some kind of benefit, such as faster development speed, code reusability.

@JanaAbuHaltam
Copy link

Jana AbuHaltam, Noor Alrai, Lujain Mansour, Mohamad Alchehabi

Q1
Redis offers a fast, in-memory data store to power live streaming use cases. Redis can be used to store metadata about users' profiles and viewing histories, authentication information/tokens for millions of users, and manifest files to enable CDNs to stream videos to millions of mobile and desktop users at a time.
it's an open source in-memory data store that can be used as a database, cache, or message broker. It's often used for caching web pages and reducing the load on servers. Redis also has some features that make it attractive for use as a database, such as support for transactions and publish/subscribe messaging.

Q2
Redis is a type of database that's commonly referred to as No SQL or non-relational, t holds its data primarily in memory, making it highly efficient for read and write operations. However, Redis also has the capability to persist data to disk, providing durability and backup options. This combination of in-memory storage and optional disk persistence enables Redis to deliver fast data access and manipulation while still ensuring data integrity and protection.

Q3
WebSocket is a technology that allows quick back-and-forth communication between a website (like a game or chat app) and a server. It's great for things that need constant, real-time updates, like chatting or online gaming. WebSocket makes this communication fast and efficient.

Q4.
1- Scheduled backups or data synchronization between different systems.
2-Regular system maintenance tasks like log rotation or database cleanup.
3-Periodic data aggregation or reporting tasks.
4-Automated scaling of resources based on time-specific requirements

Q5
1- Creational Patterns: These patterns provide ways to create objects while hiding the creation logic, creating a separation of concerns. Examples of creational patterns include the Singleton pattern, Factory pattern, and Constructor pattern.

2- Structural Patterns: Structural design patterns deal with how objects are composed to form larger structures. Examples in Node.js include the Module pattern, Decorator pattern, and Facade pattern.

3- Behavioral Patterns: Behavioral design patterns focus on how objects communicate and interact with each other. In Node.js, examples include the Observer pattern, Pub/Sub pattern, and Promises pattern.

@belalninja
Copy link

belalninja commented Feb 1, 2024

Room 1: Yassin, Mohammad smadi, Musab, Belal

1. What is Redis? Mention one use case of Redis.

2. What type of database is Redis and where does it hold its data?


Redis is an open-source in-memory data store that works really well as a cache or message broker, It offers excellent performance, with the ability to quickly read and write data to memory.
An in-memory database is a type of database that stores data entirely in main memory (RAM) rather than on disk.
image
It can be used in cases where Real-time analytics are required, or in social media cases for ad personalisation.

3. What is WebSocket and what is it used for?


Websocket API is a realtime technology that's used to open a two-way interactive communication session between the user's browser and a server. it's like a constantly opened tunnel between two parties that can be used to pass data back and forth until one of the parties terminates the connection
image

4. Explain 3 use cases for CRON jobs.


  1. Data backup: we can set a scheduled task to backup specific data from a database every set time.
  2. Server status: it can be used to check the status of the server constantly
  3. Sending automated reports: Generating and sending reports on a scheduled basis.

5. What are the 3 types of design patterns in Nodejs?


  1. Creational Design Pattern
  2. Structural Design Pattern
  3. Behavioral Design Pattern

@ramah-madi
Copy link

ramah-madi commented Feb 1, 2024

Najwan Shawareb, Abdullah Alawad, Ramah Madi

Q1. Redis is an open-source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine.
Redis can be used to store metadata about users' profiles and viewing histories, authentication information/tokens for millions of users, and manifest files to enable CDNs to stream videos to millions of mobile and desktop users at a time.

Q2. Open-source (BSD licensed), in-memory data structure store.

Q3. WebSockets are a protocol for bi-directional, real-time communication between a client and a server over a single, long-lived connection. Unlike traditional HTTP requests, which are unidirectional and require a new connection for each request, WebSockets allow for continuous communication between the client and server.

Q4. Scheduled backups or data synchronization between different systems.
Regular system maintenance tasks like log rotation or database cleanup.
Periodic data aggregation or reporting tasks.

Q5. 1. the Factory pattern.
2. the Revealing Constructor pattern, the Builder pattern.
3. the Builder pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment