Starting with Redis in ASP.NET

What is Redis
Redis Cache is a NoSQL key-value database that runs entirely in memory. As a database that runs in memory its very fast,faster than typical database systems

Why use Redis Cache
The speed advantage of Redis means that there is much less performance overhead when reading and writing data. If you have an application that needs to store/cache lots of data and you have memory to spare then Redis might be exactly what you are looking for.

License and Cost
Its free to use for both non-commercial and commercial uses under the BSD license

Why not caching
Redis has great advantages over traditional memory caching,it persists to disk and its data is available across applications rather than a single process.

Read More…

Strategy Design Pattern

Strategy design pattern is a behavioral design pattern.In theory,the Strategy Pattern means:

A family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from the clients that use it.

To implement this pattern our system code will be divided into the following components
Read More…

Should you use both AngularJS and ASP.NET MVC together?

One of a common question that new users come up is that should we use both AngularJS and ASP.NET MVC together in a project.Both these are based on MVC frameworks so should we use them both in same application.If so when and if not why?

Well the answer to this question is based on the type of application you are building.If you are building a single page application (SPA), then you probably don’t need the “MVC” in ASP.NET MVC. Views, especially dynamic views, are likely delivered/manipulated client-side. Angular handles that just fine.

Read More…

Design Patterns – Factory Method Pattern

Factory method pattern is a creational Pattern.By this we mean it is used to create objects. People usually use this pattern as the standard way to create objects

What is Factory Method Pattern?
Factory Method Pattern is a pattern by which we develop an abstraction which hides the logic for creation of an object

Factory Method Pattern has four building blocks

ProductBase
ConcreteProduct
FactoryBase
ConcreteFactory

ProductBase
This the abstract class or an interface for the products that would be created by the factory
Read More…

Assign static IP Address to Ubuntu box

Below are the steps to assign static IP address to a box running on Ubuntu OS.

Step 1 : Identify Ethernet Interfaces

To quickly identify all available Ethernet interfaces, you can use the ifconfig command as shown below.

ifconfig -a | grep eth
ens150 Link encap:Ethernet HWaddr 00:15:c5:4a:16:5a

Now open interfaces using a text editor to update as below

sudo vim /etc/network/interfaces

Read More…

Install Gitlab on Apache in Ubuntu

Below are the steps i followed in successfully installing gitlab on my Ubuntu running on Apache web server.

Install necessary packages
sudo apt-get install curl openssh-server ca-certificates postfix

Download and install the gitlab package
curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_8.15.2-ce.0_amd64.deb/download
dpkg -i gitlab-ce_8.15.2-ce.0_amd64.deb

Stop GitLab services
$ gitlab-ctl stop

Disable bundled Nginx
In /etc/gitlab/gitlab.rb set:

nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"

Read More…

Add a ftp user to upload files in Ubuntu

We would be creating and setting up a linux user with read and write permissions for your web document root, usually the /var/www/html directory. Connecting with this user via SFTP will let you upload your website content directly to the /var/www/html/yoursitefolder.

For the purposes of this example we’ll use an account named “ftpuser ”.
On Debian-based systems apache runs under the group “www-data” with a document root of “/var/www/html”.

Create a new user

To create a new user “ftpuser” enter the below command

sudo useradd -d /var/www/html -G www-data ftpuser

Now to set password to the account enter

sudo passwd ftpuser

Read More…