35+ Memcached Interview Questions

35+ Memcached Interview Questions

Memcached Interview Questions

What is Memcached? 

Memcached is a universally useful free and open source, elite, appropriated memory object reserving framework. It is utilized to accelerate database-driven sites by reserving information and items in RAM.
In straightforward words, you can say that Memcached is a part which stores information transiently for 1hour/6 hour/12 hours/1 day, and so on and you can coordinate this segment with your applications to build their execution.

In which language Memcached is composed and who is the creator? 

Memcached is written in "C language". It was created by Brad Fitzpatrick in 2003. At first, it is produced for LiveJournal, however at this point it is utilized by Wikipedia, Twitter, Facebook, Flickr, Netlog, YouTube, and so on.

How Memcached works? 

See the accompanying strides to see how Memcached functions:

  • Memcached first endeavors to get the detail of the client, and the program sends the demand to the application. 
  • An application calls the Memcached for a specific client. 
  • On the off chance that Result found in Memcached, Return the outcome from Memcached. 
  • On the off chance that Result Not found in Memcached, Application sends the demand to the database and spare the outcome in Memcached. 
  • Each Memcached have one interesting key. 
  • Get/Set the information deal with benefit of the key. 
  • You can likewise erase at least one keys. 
  • You can likewise dole out labels to one/more keys. 

When was the main rendition of Memcached propelled? 

The principal adaptation of Memcached was propelled on May 22, 2003.

What is the utilization of Memcached? In which kinds of sites, it is commonly utilized? 

Memcached is utilized to expand the speed of dynamic database driven sites. It reserves information and items in RAM to decrease the execution time.

  • It is commonly utilized: 
  • In long range informal communication destinations for profile storing. 
  • For substance conglomeration for example HTML/Page storing. 
  • In E-trade sites for Session and HTML storing. 
  • In area based administrations for database inquiry scaling. 
  • In gaming and amusement administrations for session storing. 
  • It can likewise be utilized to follow treat/profile for advertisement focusing on. 

What is the best utilization of Memcached? 

Best utilization of Memcached: 
  • It is anything but difficult to introduce in Windows just as in the UNIX working framework. 
  • It gives API reconciliation to all the real dialects like Java, PHP, C/C++, Python, Ruby, Perl, and so forth. 
  • It upgrades the execution of web application by reserving. 
  • It diminishes the weight of the database server. 
  • It encourages you to erase at least one qualities. 
  • It encourages you to refresh the estimations of keys.

Can we share a solitary occasion of Memcache between different activities? 

Indeed, we can share a solitary occurrence of Memcache between numerous activities in light of the fact that being a memory storage room, Memcache can be kept running on at least one servers. In Memcache, you can likewise design your customer to address a specific arrangement of examples.

We can likewise run two diverse Memcache forms on a similar host being totally autonomous and with no obstruction. In the event that you parcel your information, it is vital to know from which occasion to get the information from or to put into.

Explain the contrasts between SAP HANA and Memcached? 

SAP HANA is an in-memory RDBMS and generally utilized for quickening SAP applications while Memcached is a key/esteem storing framework and utilized for getting to both RDBMS and NoSQL databases.

How to associate Memcached server with telnet direction? 

By utilizing telnet hostname portNumber direction, you can associate Memcached server with telnet order.
Punctuation
$telnet HOST PORT
Precedent 
The given precedent tells that the best way to associate with a Memcached server and execute a straightforward set and get direction. We should accept that the server of Memcached is running on host 127.0.0.1 and port 11211.
$telnet 127.0.0.1 11211
Attempting 127.0.0.1...
Associated with 127.0.0.1.
Getaway character is '^]'.
/store information and get that information from server
set bipinwebacademy 0 900 9
memcached
Put away
get bipinwebacademy
Esteem bipinwebacademy 0 9
memcached
END
13) How to get the estimation of key?
By utilizing the get direction, you can get the estimation of the key.
Sentence structure
get key
Model
In the given model, we use bipinwebacademy as the key and store Memcached in it with a termination time of 900 seconds.
import net.spy.memcached.MemcachedClient;
open class MemcachedJava {
open static void main(String[] args) {
/Connecting to Memcached server on localhost
MemcachedClient mcc = new MemcachedClient(new
InetSocketAddress("127.0.0.1", 11211));
System.out.println("Connection to server sucessfully");
System.out.println("set status:"+mcc.set("bipinwebacademy", 900, "memcached").done);
/Get an incentive from store
System.out.println("Get from Cache:"+mcc.get("bipinwebacademyt"));
}
}

How to set the estimation of key? 

By utilizing set order, you can set the estimation of the key.
Linguistic structure
set key banners exptime bytes [noreply]
esteem
Precedent 
In the given precedent, we use bipinwebacademy as the key and set esteem Memcached in it with a lapse time of 900 seconds.
set bipinwebacademy 0 900 9
memcached
Put away
get bipinwebacademy
Esteem bipinwebacademy 0 9
Memcached
END

How to include an incentive in the key? 

By utilizing include order, you can include an incentive in the key. 
Grammar
include key banners exptime bytes [noreply]
esteem
Model
In the given model, we use "key" as the key and include the esteem Memcached in it with 900 seconds termination time.
include key 0 900 9
memcached
Put away
get key
Esteem key 0 9
Memcached
END

How to supplant the estimation of the key? 

By utilizing supplant direction, you can supplant the estimation of the key. 
Grammar
supplant key banners exptime bytes [noreply]
esteem
Model
In the given model, we use "key" as the key and include the esteem Memcached in it with 900 seconds lapse time. After this, a similar key is supplanted with the "redis".
include key 0 900 9
memcached
Put away
get key
Esteem key 0 9
memcached
END
supplant key 0 900 5
redis
get key
Esteem key 0 5
redis
END

How to add the estimation of the key? 

By utilizing add direction, you can attach the estimation of the key. 
Language structure
attach key banners exptime bytes [noreply]
esteem
Model
In the given model, we are attempting to include a few information in a key that does not exist. Henceforth, NOT_STORED is returned by Memcached. After this, we set one key and add information into it.
add bipinwebacademy 0 900 5
redis
NOT_STORED
set bipinwebacademy 0 900 9
memcached
Put away
get bipinwebacademy
Esteem bipinwebacademy 0 14
memcached
END
add bipinwebacademy 0 900 5
redis
Put away
get bipinwebacademy
Esteem bipinwebacademy 0 14
memcachedredis
END

How to prepend estimation of key? 

By utilizing prepend direction, you can prepend estimation of the key. 
Grammar
prepend key banners exptime bytes [noreply]
esteem
Model
In the given model, we are attempting to include a few information in a key that does not exist. Henceforth, NOT_STORED is returned by Memcached. After this, we set one key and prepend information into it.
prepend instructional exercises 0 900 5
redis
NOT_STORED
set instructional exercises 0 900 9
memcached
Put away
get instructional exercises
Esteem instructional exercises 0 14
memcached
END
prepend instructional exercises 0 900 5
redis
Put away
get instructional exercises
Esteem instructional exercises 0 14
redismemcached
END

How to erase the key? 

By utilizing erase direction, you can erase the key. 
Linguistic structure
erase key [noreply]
Precedent
In the given precedent, we use bipinwebacademy as a key and include the esteem Memcached in it with 900 seconds termination time. After this, it erases the put away key.
set bipinwebacademy 0 900 9
memcached
Put away
get bipinwebacademy
Esteem bipinwebacademy 0 9
memcached
END
erase bipinwebacademy
Erased
get bipinwebacademy
END
erase bipinwebacademy
NOT_FOUND

How to demonstrate the details? 

By utilizing details order, you can demonstrate the details. 
Linguistic structure
details
Precedent
details
Detail pid 1162
Detail uptime 5022
Detail time 1415208270
Detail adaptation 1.4.14
Detail libevent 2.0.19-stable
Detail pointer_size 64
Detail rusage_user 0.096006
Detail rusage_system 0.152009
Detail curr_connections 5
Detail total_connections 6
Detail connection_structures 6
Detail reserved_fds 20
Detail cmd_get 6
Detail cmd_set 4
Detail cmd_flush 0
Detail cmd_touch 0
Detail get_hits 4
Detail get_misses 2
Detail delete_misses 1
Detail delete_hits 1
Detail incr_misses 2
Detail incr_hits 1
Detail decr_misses 0
Detail decr_hits 1
Detail cas_misses 0
Detail cas_hits 0
Detail cas_badval 0
Detail touch_hits 0
Detail touch_misses 0
Detail auth_cmds 0
Detail auth_errors 0
Detail bytes_read 262
Detail bytes_written 313
Detail limit_maxbytes 67108864
Detail accepting_conns 1
Detail listen_disabled_num 0
Detail strings 4
Detail conn_yields 0
Detail hash_power_level 16
Detail hash_bytes 524288
Detail hash_is_expanding 0
Detail expired_unfetched 1
Detail evicted_unfetched 0
Detail bytes 142
Detail curr_items 2
Detail total_items 6
Detail removals 0
Detail recovered 1
END

How to get the adaptations? 

By utilizing Version order, you can get the adaptations.

How to close the association? 

By utilizing the Quit order, you can close the association.

How might you refresh Memcached when information changes? 

There are two strategies to refresh Memchached when information changes: 

  • By clearing the reserve proactively: You can refresh Memcached by clearing the store while addition or updation is made. 
  • By resetting the reserve: It is somewhat like the main technique, yet it doesn't erase the keys and sit tight for the following solicitation for the information to revive the store, it resets the qualities after the supplement or refresh. 

What is Dogpile impact? How might you keep this impact? 

On the off chance that the store lapses, and sites are hit by various solicitations made by the customer in the meantime, this impact is known as Dogpile impact.

This impact can be counteracted by utilizing a semaphore lock. In this framework when esteem terminates, the principal procedure secures the lock and begins producing new esteem.

What happens to the information put away in Memcached when server coincidentally gets shut down? 

In Memcached, information isn't for all time put away. It's anything but a strong information in this way, if the server is closed down or restarted, every one of the information put away in Memcached will be erased.

If you have numerous Memcache servers and one of the Memcache servers fizzles which has your information, will it ever endeavor to get key information from that one fizzled server? 

The information in the fizzled server won't get evacuated, however there is an arrangement for auto-disappointment, which can be designed for various hubs. Bomb over can be activated amid any attachment or Memcached server level mistakes and not amid ordinary customer blunders like including a current key, and so forth.

How would you be able to limit the Memcached server blackouts? 

Following are the techniques to limit the Memcached server blackout: 

When one example comes up short, a few of them go down, this circumstance will put bigger burden on the database server when the customer reloaded the lost information. To maintain a strategic distance from this, you ought to compose your code to limit store rushes, and it will leave a relatively less effect. You can raise an occasion of Memcached on another machine utilizing the lost machines IP address.

The Code is another choice to limit server blackouts as it gives you the freedom to change the Memcached server list with insignificant work.

Setting timeout esteem is another alternative that some Memcached customers actualize for Memcached server blackout. At the point when your Memcached server goes down, the customer will continue attempting to send a demand till the time-out utmost is come to.