Skip to main content

Posts

Showing posts from September, 2023

Redis

  Redis is considered better than some other in-memory caching solutions for specific reasons that set it apart. While many cache systems share some common features, Redis excels in several key areas: Versatile Data Structures: Redis offers a wide range of data structures beyond simple key-value pairs, including lists, sets, sorted sets, and hashes. This versatility allows you to model your data more effectively within the cache. Some other caches might be limited to basic key-value storage. Persistence Options: Redis provides flexible persistence options, including snapshots and append-only files, which allow you to combine caching with data durability. This is especially important for applications where data integrity is critical. Many other in-memory caches prioritize caching performance over persistence. Advanced Cache Expiry Policies: Redis allows you to set expiration times on keys, which is a common caching requirement. However, Redis offers various eviction policies (e.g...

Strategy Pttern

Strategy Pattern:  Intent: The Strategy Pattern is also a behavioral design pattern, but its primary intent is to define a family of interchangeable algorithms, encapsulate each one, and make them interchangeable. It allows the client to choose the appropriate strategy at runtime. Usage: It's used when you have a set of related algorithms or behaviors and you want to make these behaviors interchangeable without modifying the client that uses them. This pattern promotes algorithm encapsulation and flexibility. Components: In the Strategy Pattern, you typically have 3 main components:  Context, Strategy, and Concrete Strategies. Context : Maintains a reference to the selected strategy and uses it to perform its operations. Strategy : Defines an interface or abstract class that represents the family of algorithms. Concrete Strategies : Implement the specific algorithms. Flexibility: The Strategy Pattern promotes flexibility by allowing you to switch between different algorithms o...

Command Pattern

Command Pattern Enclose your request under an object as a command and pass it to the object which can invoke the appropriate behavior by using appropriate object which will handle the passed command and execute it. Its an Action Advantage  It separates the invoker and the executor based on command operation. for example an invoker will invoke the relevant object for command execution. New command can be easily added. It command pattern, have 4 actors. Command Request : Encapsulates command and its parameters. Receiver : who knows how to perform the requested action. Invoker : Sends the command request Client : create and configure the command and the invoker. Usage When parametrized object is required as per required action creation and execution of request at different times when logging , transaction, rollback is required Its often used in a scenarios where you want to decouple the sender (client) of the request from the receiver (the object that performs the action) and provide ...