Nirutechnolabs

Learning & Integrating web technology and code help directory

find command examples UNIX / Linux Commands

find command examples

Find files using file-name ( case in-sensitve find)
# find -iname "MyCProgram.c"
Execute commands on files found by the find command
$ find -iname "MyCProgram.c" -exec md5sum {} \;
Find all empty files in home directory
# find ~ -empty

grep command examples UNIX / Linux Commands

grep command examples

Search for a given string in a file (case in-sensitive search).
$ grep -i "the" demo_file
Print the matched line, along with the 3 lines after it.
$ grep -A 3 -i "example" demo_text
Search for a given string in all files recursively
$ grep -r "ramesh" *

tar command examples using UNIX / Linux Commands

tar command examples

Create a new tar archive.
$ tar cvf archive_name.tar dirname/
Extract from an existing tar archive.
$ tar xvf archive_name.tar
View an existing tar archive.
$ tar tvf archive_name.tar

History Of SAP Software

History Of SAP Software

From day one, SAP was created as a global software product.
The software was engineered on a multilingual and multinational platform. 
Only a few years after its core product hit the marketplace the SAP become Germany's top software vendor.
 
SAP AG also offers comprehensive industry solutions besides regular SAP software (ECC products).
Examples are SAP Aerospace & Defense, SAP Automotive, SAP Banking, SAP Chemicals, SAP Consumer Products, SAP Engineering & Construction, SAP Healthcare, SAP High Tech, SAP Insurance, SAP Media, SAP Oil & Gas, SAP Pharmaceuticals, SAP Public Sector, SAP Retail, SAP Service Provider, SAP Telecommunications, SAP Utilities.
 
WebAS is very flexible.
Due to this flexibility an orgranization can initially choose to deploy SAP system very similar to how they do business today, and then gradually evolve business model over time.  
 
Client/server is of a few architectures available. 
In a client/server environment, a client machine requests information, via network, from the supplying machine, known as the server. 
A client machine could be an individual PC, workstation, mobile computing device, or even another computer system.
 
Img1
 
The three-tiered architecture divides the architecture into three layers: 
·         The user interface layer 
·         The business logic layer ("application" layer) 
·         The database layer
 
Img2
 
The four-tiered system enables simple browser-based access.
This laywer helps in reducing the expense associated with installing, patching, and upgrading the SAP GUI user interface across perhaps hundreds or thousands of desktops.
Also it helps to integrate web services into the overall architecture.
 
Designing an adaptable enterprise computing solution is now possible using ESA. 
Using ESA, SAP R/3 and other legacy SAP solutions can be plugged in as application services. 
 
 

Learn ERP & CRM

ERP Overview
ERP stands for Enteprise Resource Planning. Enteprise Resource Planning software is often referred to as the backbone for the entire business. Using medical analogy an ERP system has brains (process logic), muscle (business transactions), and heart (business policy). ERP system communicates (as a nervous system) across business functions. ERP systems grow and evolve over time. If left unattended, it can get soft and flabby. The freshly implemented system is not very stable, like your legacy system. Users might not like your newly born ERP system until it matures.

Attributes of ERP Systems
 Leading ERP systems supports industry standards and best practices.
The Oracle Applications and SAP supports recommendations of the American Production and Inventory Control Society (APICS) and Generally Accepted Accounting Practices (GAAP).
The ERP system is composed of many modules called applications.

ERP Advantages
ERP advantages drive implementation projects.
Companies implement ERP systems for various reasons.
The reasons could be tangible, intangible, or strategic.
Due to these intangible and strategic benefits most companies do not even try to calculate a total return on investment from an ERP system.

ERP Disadvantages
ERP disadvantages must be overcome.
ERP systems comes with their share of headaches. 
They are usually difficult to implement.
Sometimes they are difficult to operate. 
In the past few years, odds of success have improved.

Application Service Providers
Recently the Application Service Providers (ASP) business model is becoming popular as a way to implement and operate your ERP applications. 
An application service provider (ASP) is a company that offers individuals or enterprises access over the Internet to applications and related services that would otherwise have to be located in their own personal or enterprise computers.

ERP Vendors
Market share 2005 according to Gartner Dataquest

#          Vendor                         Revenue (million $)      Market share(%) 
1           SAP                                   4726                                     28.7
2           Oracle Applications           1674                                     10.2
3           The Sage Group               1221                                      7.4
4           Microsoft Dynamics           616                                       3.7
5           SSA Global Technologies  464                                       2.8

Microsoft Dynamics CRM 3.0
Each businesses is different.
Unique set of tools are used by each to manage their customers.
Companies must make sure that their customer management software can easily adjust to their needs.

Need For CRM
Few examples of bad customer service experiences are:
·      You called a customer service phone number and were transferred to five different people.  Every single person asked you the same questions, so you had to keep repeating the same answers over and over again.
·      A salesperson pulled together a proposal for you but forgot to include your preferred-customer pricing in the quote.
·      A credit card company mailed you an application for a new account, even though you've had an account with that company for 10 years.

CRM Challenges
Some of the factors that make a CRM strategy difficult to implement include:
·         Multiple customer management systems
·         Remote workers
·         Rapidly changing business processes
·         Multi-channel customer interactions
·         Difficult and rigid systems

CRM Benefits
Following are the examples benefits that a company would get from successful implementation of CRM software.
·     CRM could track customer interests and purchase history over time. It proactively generate new marketing initiatives for customers based on their unique histories.
·     CRM could log a history of a customer's service requests.  A service technician could easily view all of those requests when the customer called with a new issue. Reviewing a customer's service history might help the technician resolve a customer's new issue much more quickly.
·      A manager could view all of the interactions with a customer across various functional areas such as sales, marketing, and customer service. People typically refer to this cross-functional history as a 360-degree view of the customer.
·     Marketing managers could analyze and report on the effectiveness of their marketing lists and campaigns to determine how they should re-allocate future marketing investments.
·      An analyst could use business intelligence tools to segment customers and prospects to identify trends and create predictive models for sales and customer service planning.

Java Intoductions

Java is widely used robust technology. let's start learning java from basic like what is java, core java where it is used, what type of applications are created in java and why we use java.

first of let's see what is java..?

Java is programming language and a platform. java is high level, robust secured and object oriented programming language.

Platform any hardware or software environment in which a program runs is known as platform. since has its own environment(JRE) and API. It is called platform.

Now onward let's see one example to know better idea will came.

Class Simple{
   Public static void main(String args[]) {
      System.out.println("Hello Ravi");
   }
 }

Out put is here:

Compile by : javac Simple.java
Run by : java Simple

Hello Ravi

Where is is used ?

Accordingly to sun, 3 billion devices run java. there are many devices where java is currently used. some of them are as follows:

  1. Desktop Applications such as acrobat reader, media player, antivirus and many popular software.
  2. Web applications such as irctc.co.in etc
  3. Enterprise Applications such as banking applications 
  4. Mobile
  5. Embedded System 
  6. Smart Card
  7. Robotics
  8. Game etc 
Types of Java Applications

There are mainly four type applications that can be crated using java programming :

1: Standalone Applications 
It's also known as desktop application or window-based applications. an application that we need to install every machine such as media player antivirus etc. AWT and Swing are used in java creating standalone applications

 2:Web Applications
An application that runs on the server side and creates dynamic page is called web applicaion. currently servlet , jsp struts, jsf etc. technologies are used creating web application in java

3:Enterprise Application 
An application that is distributed in nature, such as banking applications etc. IT has the advantage of high level security load balancing and clustering. in java EJB is used for creating enterprise applications.

4:Mobile Application
An application that is created for mobile devices. currently android and java ME are used for creating mobile applications.

History of Java

Java is interesting to know the history if java starts from green team. java team




 

30 New Social Bookmarking Sites List for Strong Backlink

Apple I phone 6s 32 GB 16999 RS.

Today I am going to share with you 30 New Social Bookmarking Sites List for Strong Backlink. Hope we all know what bookmark means. He/She who do not know about this, I request you to take help from Wikipedia to understand about Bookmark. I appreciate to know the real thing before starting anything. The so called seo masters know how to do social bookmark and they also know that this is a way to create strong backlink. But they do not know “how it works”  and “What it is”. In short I can say, one should not remember all the websites’ name what they needs all time. But if one saved it in a particular website, he/she could easily find out it. This is called the bookmarking. But we are doing this for creating backlinks. I am giving you 30 new backlink sites. You all can easily sign up here and create backlinks for your website.


01. http://b.emploodle.com/
02. http://b.safefashionsolution.com/
03. http://b.myanxietyinsightsblog.com/
04. http://b.bestselfhelpcenter.com/
05. http://b.bestlaptopsdealslab.com/
06. http://b.fitnessinsightsblog.com/
07. http://b.justweightlossfacts.com/
08. http://b.makemoneyonlinedata.com/
09. http://b.beautyproductsportal.com/
10. http://b.cellphonesinfozone.com/
11. http://b.justkitchenfacts.com/
12. http://b.myonlineeducationblog.com/
13. http://b.nutritioninsightslist.com/
14. http://b.photographychoicesblog.com/
15. http://b.sportsinsightszone.com/
16. http://b.thebestclothinghub.com/
17. http://b.thecarelectronicszone.com/
18. http://b.cookingrecipeshub.com/
19. http://b.eatingdisordershub.com/
20. http://b.marriageadviceportal.com/
21. http://b.musicalinstrumentsportal.com/
22. http://b.pccomponentsblog.com/
23. http://b.newpersonalgrowthinfo.com/
24. http://b.mydatingtipscenter.com/
25. http://b.bettingsystemsinfozone.com/
26. http://b.applianceslisthub.com/
27. http://b.dogtraininginsights.com/
28. http://b.outdoorgearchoices.com/
29. http://b.patiofurnituredealshub.com/

30. http://b.leadershipinsightsblog.com/

oDesk Upwork cover letter samples

oDesk/Upwork Cover Letter for SEO (Search Engine Optimization)

Dear Hiring Manager/Hello

I’ve carefully gone through your job posting on “SEO Expert”. I ’m an expert Search Engine Optimizer with more than 2 years experiences of both “On-Page” and “Off -Page” SEO. I am very much interested in your project with all of your requirements.
Recently I have successfully completed a SEO project on “A project name” both on-page and Off- page SEO, Full white hat Complying with Google Panda and Penguin Updates.
For more on my skill and successfully finished jobs, please have a look on my Profile, Portfolio, Work history and Feedback. You can see my official site also “nirutechnolabs” (If you have not any site, please delete this line)
I am always available on Email(nirutechnolabs@gmail.com) and Skype(nirutechnolabs). Please have a voice or video chat if necessary. I will be available more than 60 hours per week and able to start your project as soon as possible according to you.

Thank you for your consideration
Best Regards
Ravi Chauhan

oDesk/Upwork Cover Letter for Article/Blog/Content Writing

Hello
I have got your job posting on “Job Title” and I am very much interested to work in your project. I am a pro blogger and content provider with more than 3 years working experiences of blog writing, Posting and SEO. So, I think you’ll find, I have the skills you’re looking for.
For more on my skill and successfully finished jobs, please have a look on my Profile, Portfolio, Work history and Feedbacks.Normally, I can write and post a blog content with graphics and all the SEO supplements within two hours.
I am always available on Email(nirutechnolabs@gmail.com) and Skype(nirutechnolabs). Please have a voice or video chat if necessary. I will be available more than 60 hours per week and able to start your project as soon as possible according to you.

Thank you for your consideration,
Best Regards,
Ravi Chauhan

oDesk/Upwork Cover Letter for Blog/Article Posting

Hello
I have got your job posting “Job Title” and I am very much interested to work in your project. I am a pro blogger and have more than 6 years experiences of blog writing, Posting and SEO. So, I think you’ll find, I have the skills you’re looking for.
For more on my skill and successfully finished jobs, please have a look on my Profile, Portfolio, Work history and Feedbacks. Normally, I can write and post a blog content with graphics and all the SEO supplements within two hours.
I am always available on Email(nirutechnolabs@gmail.com) and Skype(nirutechnolabs). Please have a voice or video chat if necessary. I will be available more than 60 hours per week and able to start your project as soon as possible according to you.

Thank you for your consideration,
Best Regards,
Ravi Chauhan

oDesk/Upwork Cover Letter for SMM (Social Media Marketing)

Dear Hiring Manager,
I’ve carefully gone through your job posting on “”. I ’m an expert Social Media Marketer with full internet marketing techniques. I have more than 6 years working experiences in SMM, IM, SEM, SEO, Affiliation, etc. I am very much interested in your project with all of your requirements.
Recently I have successfully completed many of SMM, IM, EM, etc.For more on my skill and successfully finished jobs, please have a look on my Profile, Portfolio, Work history and Feedbacks. You can see my official site also http://www.nirutechnolabs.com
I am always available on Email(nirutechnolabs@gmail.com) and Skype(nirutechnolabs). Please have a voice or video chat if necessary. I will be available more than 60 hours per week and able to start your project as soon as possible according to you.

Thank you for your consideration,
Best Regards,
Ravi Chauhan

oDesk/Upwork Cover Letter for Youtube Channel Optimization/SEO

Hello
I’ve carefully gone through your job posting on “Job Title”. I ’m an expert Youtube Channel Optimizer with more than 6 years experiences of both “On Channel” and “Off Channel” Optimization and SEO. I am very much interested in your project with all of your requirements.
Recently I have successfully completed two jobs on youtube channel optimization, http://www.youtube.com/user/nirutechnolabs; 
http://www.youtube.com/user/ravischauhan007
For more on my skill and successfully finished jobs, please have a look on my Profile, Portfolio, Work history and Feedbacks. You can see my official site also http://www.yoursitename.com
I am always available on Email(nirutechnolabs@gmail.com) and Skype(nirutechnolabs). Please have a voice or video chat if necessary. I will be available more than 60 hours per week and able to start your project as soon as possible according to you.

Thank you for your consideration,
Regards
Ravi Chauhan

oDesk / Upwork Cover Letter for Graphics Design/Logo/Banner

Hello
I am Your Name. I have completed my Diploma in Graphics Design and Text Illusion from Any University Name or Training Company Name. For the past few years I have designed many logos, banners, 3D textures, Auto Cad, Cartoons etc. Some samples have been posted in my portfolio area and my work history area. Please have a look to measure my quality.
From your job description area, I have come to know that you need a unique design for your new/existing company. Actually graphics is the soul of a website and permanent branding of a company. I can strongly assure you that I will be able to provide you according to your desire.
You will find so many so called designers in the web who even do not know the color combination and structure. I do not want you to be cheated by them. You are in a right place and person. Hopefully I will be hired in this project. I am highly experienced in
  1. Adobe Photoshop, 2. Adobe Illustrator, 3. Adobe Flash, 4. lnDesign, 5. Corel Draw, 6. Text Design Pro
I am waiting for your response. I am able to use all types of communication methods and able to maintain your time schedule during the project is on.

Regards:
Ravi Chauhan

oDesk/Upwork Cover Letter for VA / Virtual Assistant

Dear hiring manager
I have got your job posting on Virtual Assistant Project. According to your job description you need a fast one for helping you in your tasks. And yes you have mentioned about your time. For your kind information I want to let you know that I have been working with these types of works for more than five years without any single time schedule problem.
I am fully expert in web research, extracting email, data mining, Google, Bing, Yahoo, MS Office (Full), Google Docs, Google Document, Google Spreadsheet, Adwords, Analytics, Webmaster, SEO, SMM, EM, SEM, PR, B2B Marketing, Lead Generation, Directory and other related programs.
I can assure you that I will be able to assist you in your task in time with quality work. I have already completed so many projects. Please have a look on my portfolio and profile. I have listed many successful projects in my work history area.
I am waiting to be hired in this project to show my skills.

Regards
Ravi Chauhan

oDesk/Upwork Cover Letter for Web Research / Data Mining / Extraction

Dear hiring manager
I have got your job posting on Data Entry Project. According to your job description you need a fast worker for your data mining and web research. For your kind information I want to let you know that I have been working with these types of works for more than five years.
I am fully expert in web research, extracting email, data mining, Google, Bing, Yahoo, MS Office (Full), Google Docs, Google Document, Google Spreadsheet, Adwords, Analytics, Webmaster, SEO, SMM, EM, SEM, PR, B2B Marketing, Lead Generation, Directory and other related programs.
I can assure you that I will be able to submit your task in time with quality work. I have already completed so many projects. Please have a look on my portfolio and profile. I have listed many successful projects in my work history area.
I am waiting to be hired in this project to show my skills.

Regards
Ravi Chauhan

oDesk/Upwork Cover Letter for SMM (Social Media Marketing)

Hello
I have got your job posting for SMM. According to your job description, I have come to know that you are searching for an expert one. Now-a-days very few people can be found who do not use social media. Social media is the second need of the online people. If one organization can capture a large number of smm traffic, success can easily come to the owner. SEM and SEO are a gradual process which results slowly, rather SMM is an instant process which results faster.
Recently I have successfully completed so many SMM projects. For more information will you please visit my work history. Success is my main aim. I gain success by hock or by crook. And I have a strong belief that I will be able to satisfy you in this project. Hope I will be hired.
I am always available on Email and Skype. I will be available more than 60 hours per week and able to start your project as soon as possible according to you.


Thank you for your consideration
Best Regards
Ravi Chauhan

Additional Questions and Answers of oDesk/Upwork Job Application

1. What past project or job have you had that is most like this one and why?

Ans: According to your job requirements, I have done many projects like yours. For more details you can check my portfolio, profiles and employment history where you will find the similar projects like your desire one.

2. Do you have suggestions to make this project run successfully?

Ans: Sure I have suggestions for you in this project. According to my concept, the updated strategy and proper methods can make this project successful. And surely I will make this project successful.

3. Which part of this project do you think will take the most time?

Ans: According to your job details, I have years of experiences in both fields. And I always use the updated techniques and win the competition. I have a strong belief that I would be able to make this project successful within short time.

4. Have you taken any oDesk/Upwork tests and done well on them that you think are relevant to this job?

Ans: Yes I have taken oDesk/Upwork Skill Tests and I have done well. You can check my tests area. Default system of odesk/Upwork tests is a good method of justify oneself. And yes I appreciate it as well as I did well in here.

5. How much time do you think it will take to accomplish the task for google results ?

Ans: Competition is everywhere. Always want to be ranked in google. But failing in this competition is problematic. And I know this problem. The problem is the so called workers do not use the updated methods where I always hit the iron when it is hot. That’s why I can assure you that I will be able to do it in short times than the rest (2+ or 3+ months)

6. What part of this project most appeals to you?

Ans: Here the two parts of this project appeal me very much, one is that all the requirements are in favor of me and the second one is I like to do these kind of job. These kind of project and job give me mental satisfaction.

7. Why do you think you are a good fit for this particular project?

Ans: I think I am a good fit for this job because I have all the qualities that you are looking for. Experience is the golden factor in this project where you find in me at least 3+ years of working experiences over all the factors in your project.

8. Do you have any questions about the job description?

Ans: Your arrangement of the job description is fully understandable and I have understood it very well. Still I have no questions about your job description. If I need any information latter, I must convey you and discuss with you in a friendly circumstances.

9. Which of the required job skills do you feel you are strongest at?

Ans: I have carefully read your job description and I have more than 3 years of working experience in both of your required skills. And I am strongest at all of your required qualities. Hope I will be the perfect worker for you in this project.

 10. What SEO jobs have you done in the past?

Ans: I have successfully completed many seo projects before, you can see my employment history and portfolio projects. I hope I will also be successful in this project. You can undoubtedly hire me.

11. How much time will you need to work on this project to see results and how will you spend your time working on this project?

Ans: I have a strong belief that I would be able to make this project successful within short time. I will spend my time working on this project hourly with white hat updated method and make it successful.

12. Have you done high quality back-linking before? if so what sites do you use?

Ans: Sure I have done high PR back-inkling before and ranked many sites. You can check my employment history and portfolio. (You can also include some links here)

13. Why should i chose you over the other 100 that have applied for this Job?

Ans:  This is a good point you have asked. Here you will found many so called worker who do not know how to work. I am totally different from them. I have a long term plan to work in here, that’s why I am here with all qualities and experiences. I am here not to cheat you rather help you.

14. What challenging part of this job are you most experienced in?

Ans: Everything is now becoming challenging, If one has to win he or she should have the proper knowledge of the present situation. And I am most experienced in this factor. Hope I will make your project successful.

15. Who have you worked with that has yielded quick results. What was the cost to client to receive positive results?

Ans: I have successfully completed many projects. You can see my portfolio and employment history. And I took the relevant cost, I never ask for high price.

16. Tell me how you would go about increasing my rankings for my website?

Ans: Ranking a website on some certain keywords are now very difficult. But if one has relevant ideas and skills about the search engines’ logarithm, he/she must win this competition. According to that I will first make your site search engine friendly then I will make it popular to others and increase its rank.

17. Why did you apply to this particular job?

Ans: I have applied to this particular job because all the requirements of this project are in favor of me and I can 100% assure you that I must be successful in this project and satisfy you. I never apply to any job what doesn’t match my skills.

18. Have you read the job description fully and understand it and feel you are an ideal candidate for the job?

Ans: Great question. I never take any attempt without having the full knowledge of a matter. I have carefully read the job description and only then I decided to apply when I thought; I am the best one for this project. You can undoubtedly hire me.

19. What questions do you have about the project?

Ans: I have read the whole job description and it is really informative. I did not found anything that is irrelevant to me. I have understood every single part of the job description. Still I have not any question about the project. If I need any further help, I must ask you.

20. Do you have previous experience? If so, do you have some examples?

Ans: This is a good question, my dear client. And yes, I have a lot of previous experiences. For more on it please check my profile, work history and feedback. I have also added some portfolio that is more relevant to your question. Thanks a lot.

21. What can you do for us that someone else can’t?

Ans: Yes, really a good question. You have seen many freelancers have applied in this project but the best one for this project should be the person who has previous experiences for the relevant skills. And I have both experiences and skills. That’s why I can proudly assure you that I will be the best one among the all workers.

22. Can you read and understand English to a reasonable standard?

Ans: Yes, I can read and understand English to a reasonable standard. Although English is my second language, I practiced it well and now I am able to fully read, write, listen and speak in English. Hope our conversation will go well during the project.

23. Why should I hire you?

Ans: Yes, really this is a good question. You have seen many freelancers have applied in this project but the best one for this project should be the person who has previous experiences for the relevant skills. And I have both experiences and skills. That’s why I can proudly assure you that I will be the best one among the all workers. Hope you have got your answers that why you should hire me?

Memcached Storage Commands

Memcached - Set Data


Memcached set command is used to set a value to key; if the key does not exist, a new key is created and value is assigned to that key.

Syntax

The basic syntax of Memcached set command is as shown below −
set key flags exptime bytes [noreply] 
value 
The keywords in the syntax are as described below −
  • key - It is the name of the unique key by which data is accessed.
  • flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire", i.e. it should not be removed from the cache unless required. If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
  • bytes - This is the length of the data in bytes that needs to be stored in Memcached.
  • noreply (optional) - This parameter informs the server not to send any reply.
  • value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.

Example

In the following example, we use −
    key → tutorialspoint
    flag → 0
    exptime → 900 (expiry time in seconds)
    bytes → 9 (size of data balue in bytes)
    value → memcached
set tutorialspoint 0 900 9
memcached
STORED

get tutorialspoint
VALUE tutorialspoint 0 9
memcached

END

Output

The output of the command is as shown below −
STORED
  • STORED indicates success.
  • ERROR indicates incorrect syntax or error while saving data.

Set Data Using Java Application

To set a key in Memcached server, we need to use Memcached set method. The set method returns Future Object. We need to includejava.util.concurrent.Future interface in order to store output of set method.

Example

import java.net.InetSocketAddress;
import java.util.concurrent.Future;

import net.spy.memcached.MemcachedClient;

public class MemcachedJava {
   public static void main(String[] args) {
   
      try{
         // Connecting to Memcached server on localhost
         MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
         System.out.println("Connection to server sucessful.");
      
         // now set data into memcached server
         Future fo = mcc.set("tutorialspoint", 900, "Free Education");
      
         // print status of set method
         System.out.println("set status:" + fo.get());
         
         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // Shutdowns the memcached client
         mcc.shutdown();
         
      }catch(Exception ex){
         System.out.println( ex.getMessage() );
      }
   }
}
This program should set the value memcached with key tutorialspoint. If the key-value pair is set successfully, the get method of Future object should return true.

Output

On compiling and executing the program, you get to see the following output −
Connection to server successful.
set status:true
tutorialspoint value in cache - Free Education


Memcached - Add Data


Memcached add command is used to set a value to a new key. If the key already exists, then it gives the output NOT_STORED.

Syntax

The basic syntax of Memcached add command is as shown below −
add key flags exptime bytes [noreply]
value
The keywords in the syntax are as described below −
  • key - It is the name of the unique key by which data is accessed.
  • flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire", i.e. it should not be removed from the cache unless required. If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
  • bytes - This is the length of the data in bytes that needs to be stored in Memcached.
  • noreply (optional) - This parameter informs the server not to send any reply.
  • value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.

Example

In the following example, we use −
    key → new_key
    flag → 0
    exptime → 900 (expiry time in seconds)
    bytes → 10 (size of data balue in bytes)
    value → data_value
add new_key 0 900 10
data_value
STORED
get new_key
VALUE new_key 0 10
data_value
END

Output

If the data is stored successfully, the output should be −
STORED
  • STORED indicates success.
  • NOT_STORED indicates the data is not stored in Memcached.

Failure Output

Now, if we try to add 'new_key' again, it should give the following error −
add new_key 0 900 5
redis
NOT_STORED

Add Data Using Java Application

To store data in a Memcached server, we use the Memcached add method.

Example

In last example, we have set key tutorialspoint. In this example, we shall try to demonstrate adding data having existing key.
import java.net.InetSocketAddress;
import java.util.concurrent.Future;

import net.spy.memcached.MemcachedClient;

public class MemcachedJava {
   public static void main(String[] args) {
   
      try{
   
         // Connecting to Memcached server on localhost
         MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
         System.out.println("Connection to server sucessful.");

         // add data to memcached server
         Future fo = mcc.set("tutorialspoint", 900, "Free Education");

         // print status of set method
         System.out.println("set status:" + fo.get());

         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // try to add data with existing key
         Future fo = mcc.add("tutorialspoint", 900, "memcached");

         // print status of set method
         System.out.println("add status:" + fo.get());

         // adding a new key to memcached server
         fo = mcc.add("codingground", 900, "All Free Compilers");

         // print status of set method
         System.out.println("add status:" + fo.get());
         
         // retrieve and check the value from cache
         System.out.println("codingground value in cache - " + mcc.get("codingground"));

         // Shutdowns the memcached client
         mcc.shutdown();
         
      }catch(Exception ex){
         System.out.println(ex.getMessage());
      }
   }
}

Output

On compiling and executing the program, you get to see the following output −
Connection to server successful.
set status:true
tutorialspoint value in cache - Free Education
add status:false
add status:true
codingground value in cache - All Free Compilers
The first 'add status' displays false because the key tutorialspoint already exists in memcached server. The second 'add status' displays true indicates that the key is successfully stored.

Memcached - Replace Data



Memcached replace command is used to replace the value of an existing key. If the key does not exist, then it gives the output NOT_STORED.

Syntax

The basic syntax of Memcached replace command is as shown below −
replace key flags exptime bytes [noreply]
value
The keywords in the syntax are as described below −
  • key - It is the name of the unique key by which data is accessed.
  • flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire", i.e. it should not be removed from the cache unless required. If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
  • bytes - This is the length of the data in bytes that needs to be stored in Memcached.
  • noreply (optional) - This parameter informs the server not to send any reply.
  • value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.

Example

For example we shall use −
    key → mykey
    flag → 0
    exptime → 900
    bytes → 10 (expiry time in seconds)
    value → data_value (size of data balue in bytes)
Here, we use 'mykey' as the key and store data_value in it. After this, the same key is replaced with 'some_other_value'.
add mykey 0 900 10
data_value
STORED
get mykey
VALUE mykey 0 10
data_value
END
replace mykey 0 900 16
some_other_value
get key
VALUE mykey 0 16
some_other_value
END

Output

The output of the command is as shown below −
STORED
  • STORED indicates success.
  • NOT_STORED indicates the data is not stored in Memcached.

Replace Data Using Java Application

To replace data in a Memcached server, you need to use the Memcachedreplace method.

Example

import java.net.InetSocketAddress;
import java.util.concurrent.Future;

import net.spy.memcached.MemcachedClient;

public class MemcachedJava {
   public static void main(String[] args) {
   
      try {
         //Connecting to Memcached server on localhost
         MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
         System.out.println("Connection to server sucessful.");

         // First add a key and value
         Future fo = mcc.set("tutorialspoint", 900, "Free Education");

         // print status of add method
         System.out.println("add status:" + fo.get());

         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // adding a new key to memcached server
         fo = mcc.replace("tutorialspoint", 900, "Largest Tutorials' Library");

         // print status of set method
         System.out.println("replace status:" + fo.get());

         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // Shutdowns the memcached client
         mcc.shutdown();
         
      }catch(Exception ex){
         System.out.println( ex.getMessage() );
      }
   }
}

Output

On compiling and executing the program, you get to see the following output −
Connection to server successful.
set status:true
tutorialspoint value in cache - Free Education
Replace status:true
tutorialspoint value in cache - Largest Tutorials' Library


Memcached - Append Data



Memcached append command is used to add data in an existing key. This data is added at the end of the previous value.

Syntax

The basic syntax of Memcached append command is as shown below −
append key flags exptime bytes [noreply]
value
The keywords in the syntax are as described below −
  • key - It is the name of the unique key by which data is accessed.
  • flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire", i.e. it should not be removed from the cache unless required. If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
  • bytes - This is the length of the data in bytes that needs to be stored in Memcached.
  • noreply (optional) - This parameter informs the server not to send any reply.
  • value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.

Example

In the following example -
  • First we store a key (tutorials) and value (memcached) to Memcached
  • Then, We retrieve the value using get command and check it
  • Then, we append "redis" to the key tutorials
  • and, we retrieve it and check again.
set tutorials 0 900 9
memcached
STORED
get tutorials
VALUE tutorials 0 14
memcached
END
append tutorials 0 900 5
redis
STORED
get tutorials
VALUE tutorials 0 14
memcachedredis
END

Output

The output of the append command is as shown below −
STORED
  • STORED indicates success.
  • NOT_STORED indicates the key does not exist in the Memcached server.
  • CLIENT_ERROR indicates error.

Append Data Using Java Application

To append data in a Memcached server, you need to use the Memcachedappend method.

Example

import java.net.InetSocketAddress;
import java.util.concurrent.Future;

import net.spy.memcached.MemcachedClient;

public class MemcachedJava {
   public static void main(String[] args) {
   
      try{
   
         // Connecting to Memcached server on localhost
         MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
         System.out.println("Connection to server sucessful.");

         // add data to memcached server
         Future fo = mcc.set("tutorialspoint", 900, "Free Education");

         // print status of set method
         System.out.println("set status:" + fo.get());

         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // try to add data with existing key
         Future fo = mcc.append("tutorialspoint", 900, " for All");

         // print status of set method
         System.out.println("append status:" + fo.get());
         
         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("codingground"));

         // Shutdowns the memcached client
         mcc.shutdown();
         
      }catch(Exception ex)
         System.out.println(ex.getMessage());
   }
}

Output

On compiling and executing the program, you get to see the following output −
Connection to server successful.
set status:true
tutorialspoint value in cache - Free Education
append status:true
tutorialspoint value in cache - Free Education for All


Memcached - Prepend Data



Memcached prepend command is used to add data in an existing key. This data is added before the existing data of the key.

Syntax

The basic syntax of Memcached prepend command is as shown below −
prepend key flags exptime bytes [noreply]
value
The keywords in the syntax are as described below −
  • key - It is the name of the unique key by which data is accessed.
  • flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire", i.e. it should not be removed from the cache unless required. If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
  • bytes - This is the length of the data in bytes that needs to be stored in Memcached.
  • noreply (optional) - This parameter informs the server not to send any reply.
  • value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.

Example

In the following example -
  • First we set a key (tutorials) and value (memcached) in Memcached
  • Then, We retrieve the value using get command and check it
  • Then, we prepend "redis" to the key tutorials
  • and, we retrieve it and check again.
set tutorials 0 900 9
memcached
STORED
get tutorials
VALUE tutorials 0 14
memcached
END
prepend tutorials 0 900 5
redis
STORED
get tutorials
VALUE tutorials 0 14
redismemcached
END

Output

The output of the command is as shown below −
STORED
  • STORED indicates success.
  • NOT_STORED indicates the key does not exist in the Memcached server.
  • CLIENT_ERROR indicates error.

Prepend Data Using Java Application

To prepend data in a Memcached server, you need to use the Memcachedprepend method.

Example

import java.net.InetSocketAddress;
import java.util.concurrent.Future;

import net.spy.memcached.MemcachedClient;

public class MemcachedJava {
   public static void main(String[] args) {
   
      try{
   
         // Connecting to Memcached server on localhost
         MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
         System.out.println("Connection to server sucessful.");

         // add data to memcached server
         Future fo = mcc.set("tutorialspoint", 900, "Education for All");

         // print status of set method
         System.out.println("set status:" + fo.get());

         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // try to add data with existing key
         Future fo = mcc.prepend("tutorialspoint", 900, "Free ");

         // print status of set method
         System.out.println("prepend status:" + fo.get());
         
         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("codingground"));

         // Shutdowns the memcached client
         mcc.shutdown();
         
      }catch(Exception ex)
         System.out.println(ex.getMessage());
   }
}

Output

On compiling and executing the program, you get to see the following output −
Connection to server successful.
set status:true
tutorialspoint value in cache - Education for All
prepend status:true
tutorialspoint value in cache - Free Education for All


Memcached - CAS Command


CAS stands for Check-And-Set or Compare-And-Swap. Memcached CAS command 'checks' and 'set' data item if and only if, no other client process has updated it since last read by this client.
For example, if in the past, we retrieved the value <key, value> as <total, 3784>. If we now try to set or modify this value using CAS command, then CAS command will first check if it is the same value or is changed by some other client. If it is changed, then we should not change it to avoid any race anomalies in the system. If the value is not modified since our last fetch, CAS now sets the updated value.
Memcached server assigns a unique 64-bit CAS token to all items stored in it. We use gets command to retrieve CAS number of any item.

Syntax

The basic syntax of Memcached CAS command is as shown below −
cas key flags exptime bytes unique_cas_token [noreply]
The keywords in the syntax are as described below −
  • key - It is the name of the unique key by which data is accessed.
  • flags - It is the 32-bit unsigned integer that the server stores with the data provided by the user, and returns along with the data when the item is retrieved.
  • exptime - It is the expiration time (seconds) of data stored in cache. A 0 value means "never expire", i.e. it should not be removed from the cache unless required. If the exptime is more than 30 days then Memcached interprets it as UNIX timestamp for expiration.
  • bytes - This is the length of the data in bytes that needs to be stored in Memcached.
  • unique_cas_token − It is a unique token number obtained from gets comamand.
  • noreply (optional) - This parameter informs the server not to send any reply.
  • value - It is the data that needs to be stored. The data needs to be given on the new line after executing the command with the above options.

Example

To execute a CAS command in Memcached, you need to obtain a CAS token from the Memcached gets command. gets command is variation of get command, it is explained in forthcoming chapter.
In this example we should see −
  • Incorrect cas statement i.e. unique cas key missing
  • casing a non-existing key
  • add a key value item
  • obtain unique cas key using gets command
  • use cas and unique_cas_key to update data item
  • use get command and check if data is updated
cas tp 0 900 9
ERROR             <− unique cas key missing

cas tp 0 900 9 2
memcached
NOT_FOUND         <− the key tp does not exist

set tp 0 900 9
memcached
STORED

gets tp
VALUE tp 0 9 1
memcached
END

cas tp 0 900 5 1
redis
STORED

get tp
VALUE tp 0 5
redis
END

Output

CAS command may produce one of the following result −
  • STORED indicates success.
  • ERROR indicates error while saving data or wrong syntax.
  • EXISTS indicates that someone has modified the CAS data since last fetch.
  • NOT_FOUND indicates that the key does not exist in the Memcached server.

CAS Using Java Application

To get CAS data from a Memcached server, you need to use Memcached getsmethod.

Example

import java.net.InetSocketAddress;
import java.util.concurrent.Future;

import net.spy.memcached.CASValue;
import net.spy.memcached.CASResponse;
import net.spy.memcached.MemcachedClient;

public class MemcachedJava {
   public static void main(String[] args) {
   
      try{
   
         // Connecting to Memcached server on localhost
         MemcachedClient mcc = new MemcachedClient(new InetSocketAddress("127.0.0.1", 11211));
         System.out.println("Connection to server sucessful.");

         // add data to memcached server
         Future fo = mcc.set("tutorialspoint", 900, "Free Education");

         // print status of set method
         System.out.println("set status:" + fo.get());
            
         // retrieve value stored for tutorialspoint from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // obtain CAS token value using gets method
         CASValue casValue = mcc.gets("tutorialspoint");

         // display CAS token value
         System.out.println("CAS token - " + casValue);

         // try to update data using memcached cas method
         CASResponse casresp = mcc.cas("tutorialspoint", casValue.getCas(), 900, "Largest Tutorials-Library");
         
         // display CAS Response
         System.out.println("CAS Response - " + casresp);

         // retrieve and check the value from cache
         System.out.println("tutorialspoint value in cache - " + mcc.get("tutorialspoint"));

         // Shutdowns the memcached client
         mcc.shutdown();
         
      }catch(Exception ex)
         System.out.println(ex.getMessage());
   }
}

Output

On compiling and executing the program, you get to see the following output −
Connection to server successful.
set status:true
tutorialspoint value in cache - Free Education
CAS - {CasValue 34/Free Education}
CAS Response - OK
tutorialspoint value in cache - Largest Tutorials-Library