Simple Message Queue using Redis

In this posts we will use Redis as a simple message queue, using list commands. Let’s say we have an application that allows the users to upload a photo. Then in the application we display the photo in different sizes like Thumb, Medium and Large. In a first implementation we could have the task of processing the uploaded image in the same request. As it is an expensive task, it would make our requests slow. Read On →

Using an Embedded Tomcat with Maven tomcat plugin

When developing a java web application using the Eclipse WTP, we need to have an installation of tomcat in the machine in order to execute the application. If you are using Maven on your project, you can use the tomcat plugin to run an embedded tomcat installation and test the application. It is very simple as you can see below. OBS: To execute the steps given in this post you need to have installed in your eclipse the m2e plugin. Read On →

Simple CRUD using Servlet 3.0, Redis/Jedis and CDI – Part 2

In this post we will focus on CDI and Servlet 3.0. You can see part 1 here. Let’s start with CDI. When I started writing the post that originated this serie, I was not thinking in writing about CDI. To be sincere I’ve never used that before. The idea of the post was to create a crud using jedis and servlets. But when I was writing the application I simply hated the idea to instantiate the beans. Read On →

Simple CRUD using Servlet 3.0, Redis/Jedis and CDI - Part 1

In this post we will build a simple user crud. The data will be stored in Redis. To interact with Redis we will use Jedis library. CDI for Depedency Injection and Servlet 3.0 for the view. Let’s start with the Redis/Jedis part. You can find some overview on Redis and Jedis in these posts. Let’s start with the User class, we can see that below: public class User { private String firstName; private String lastName; private String email; private String gender; private long id; } Now let’s define the keys we will use to store the user information on Redis. Read On →

Using Redis Hash with Jedis

Redis Hashes are maps between string fields and string values, so they are the perfect data type to represent objects (eg: A User with a number of fields like name, surname, age, and so forth) That is the definition we have on redis documentation. So, lets start with a simple user class that could be seen below: public class User { private String username; private String email; private String password; private String firstName; private String lastName; } Using Jedis we are able to store an object of this class in Redis, let’s see an example: Read On →

Using Sorted Sets with Jedis API

Sorted Sets and Jedis In the previous post we started looking into Jedis API a Java Redis Client. In this post we will look into the Sorted Set(zsets). Sorted Set works like a Set in the way it doesn’t allow duplicated values. The big difference is that in Sorted Set each element has a score in order to keep the elements sorted. We can see some commands below: import java.util.HashMap; import java. Read On →

Getting Started With Jedis

Hi, These days I started looking into Redis. I’ve heard a lot about it so I decided to have a try. Redis is defined in its websites as “an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets”. We can find very good examples on where Redis is a good fit on the Shades of Gray blog. Read On →

Objetos e classes em javascript

Olá Pessoal, Este é o meu primeiro screencast e estarei falando um pouco a respeito de criação de classes e objetos com javascript. Por se tratar do primeiro, então temos muitos pontos a melhorar :), por isso sugestões são muito bem vindas para que possamos melhorar os próximos screencasts. Segue o vídeo abaixo: [vimeo http://www.vimeo.com/36342552 w=400&h=300] Objetos e classes com javascript from Francisco Junior on Vimeo.

Batch Insert with JDBC

Hi, In the current project I’m working on, we had a requirement to import some data from an Excel Spreadsheet and import them into the database. So, bascially we need to read from the spreadsheet and insert into the database. Initally we started using single insert statements, but we realized that wouldn’t be a good choice, for performance reasons. If we have a spreadsheet with too much data, we could decrease the database performance with so many single statements executed. Read On →

Private variables in javascript

In OOP we learned the importance of the encapsulation. In java we could encapsulate a variable through the keyword private, that says that variable is visible only in that object. In javascript we don’t have a specific keyword like that, but there are different ways to accomplish this behavior. In this post I’ll talk about two ways of doing that: 1- Declaring function scoped variables using var: Let’s say we have an contructor function called User, and this function defines that an user object will have the following properties: Read On →