facebook data storage api can really be the replacement of memcache

why not! all you need is a fast-n-furious caching storage for your facebook application which stores values against a key, same like a hash table. facebook data storage api does the same for you. using the batch api in facebook rest client you can seriously think it as an alternative of memcache. there are many developers who cache the data using memcache. memcache is definitely the state of the art caching solution for those who can afford hosting their application in a dedicated or vps server and knows how to install and successfully manage it. it. in other hand, facebook’s data storage api is an excellent solution for those who really want to make use of this awesome development platform without minimum hassle. all you have to do is remember some api and thats it.

lets see how you can use the facebook data storage api.

1. create the object manually (not using api)
an object in data storage api stands for something like a table. it contains some properties (columns) and their values(field values) stored against a key (think about a primary id). using the application control panel you can easily create such an object.

a. visit http://www.facebook.com/developers/apps.php?ret=2
b. select your application and click the link “http://www.facebook.com/developers/dsadmin.php?app_id={your application id}”

from this page you can create an object and create the properties. lets consider that the object name is ‘comics’ and the properties are “comicname[string]” and “comicurl[text/blob]”.

2. insert data into this object
using the storage api you can insert data into this object against a hash value. for example, lets have a look at the following piece of code

//after initializing the app client
//set value to the properties in a batch process
$facebook_api_client->data_setHashValue("comics","nancy","Nancy And Sluggo","comicname");

the example showed above will set the value of two properties in “comics” object against the common key “nancy”.

setting up the values to the properties of an object in a batch process will speed up your application execution time by running all the api calls in that batch at once. the same thing applies if you want to retrieve the values of those properties.

3. retrieve the values
now when you need to re use the value of that object in your facebook application, you can do it like this

//retrieve the values of two properties "comicname" and 'comicurl"
$comicname = $facebook_api_client->data_getHashValue("comics","nancy","comicname");
$comicurl = $facebook_api_client->data_getHashValue("comics","nancy","comicurl");

thats a tiny introduction to the storage api of facebook. there are lots more you can do by defining associations (much like table relations between two tables) and other available apis in this category. i will focus some of them in my upcoming blog posts.

before ending, revise the title of this blog post as “facebook data storage can really be the replacement of memcache for facebook application developers”.


  1. @Trophaeum

    heh heh, you can shoot me but seriously, i suggested this with complete sense. did you notice there terms

    “facebook application”
    in a facebook application there are so many rest calls that you will find it really not mentionable instead of “real caching like memcache”

    “begin batch”
    i could show the example without this one, but as it is part of the batch, it will save some extra microseconds.

    and as the name “cache” indicates, it is really for many of developers who use cache engines just for storing data temporarily (not as a performance booster) and in that case, facebook data storage is really a handy one.

    thanks for your comment 🙂

  2. Проф раскрутка страниц в вебе основной вид деятельности компании “Badabam” с 2004 года. Мы предлагаем профессиональную раскрутку страниц в поисковых системах – Yandex (yandex), Рамблер, Гугл, Mail.Ru. В собственной работе мы используем лишь “белоснежные” способы раскрутки страниц в поисковиках. Ежели Вам нужна проф, дешевая, раскрутка сайта с финансовыми гарантиями – звоните в данный момент 517-23-23!
    Раскрутка сайта, изготовка страниц, мастерски, недорого – Badabam.

Leave a comment

Your email address will not be published. Required fields are marked *