# Its a possibility to Cache Webservice Responses using Key Value?

**URL:** <https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638>\
**Category:** Elasticsearch\
**Created:** [November 16, 2015, 4:05am UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638 "2015-11-16T04:05:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebaherrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebaherrera/32/6969_2.png) [@sebaherrera](https://discuss.elastic.co/u/sebaherrera)\
**Post date:** [November 16, 2015, 4:05am UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638/1 "2015-11-16T04:05:10Z")

</div>

Ebay webservices request developers to cache results, in order to limit amounts of calls to servers and to receive ebay approval as a certified application. (raise api limits from 5k to 1.5mk).

One possibility Im thinking about is to create a store key-value to retrieve a particular search. if a file is created which key can be trigger to detect the same kind of search parameters

Currently the following information is retrieved in each call I perform to ebay servers.

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/20275b1f160e23e54d1bf4311bce62c2f8107bdf.png)

My main question is: its possible to use elasticsearch as a key/value storage engine. where the value is the webservice response and the key is something like the relevant search parameters or the API call URL/XML in md5() format to hit the cache when a webuser request the same information?

any guideance, link or tutorial would be very appreciated, Im new in Elasticsarch. thank you.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 16, 2015, 4:16am UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638/2 "2015-11-16T04:16:36Z")

</div>

You could use ES for this yes.

We have a number of clients that we provide to make it easy to interact with ES, so take a look [here](https://www.elastic.co/guide/en/elasticsearch/client/index.html) for something that you are comfortable with!

---

<div class="post-metadata">

**Author:** ![sebaherrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebaherrera/32/6969_2.png) [@sebaherrera](https://discuss.elastic.co/u/sebaherrera)\
**Post date:** [November 16, 2015, 5:26am UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638/3 "2015-11-16T05:26:22Z")

</div>

thank you Mark, reading the php client now..

---

<div class="post-metadata">

**Author:** ![sebaherrera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebaherrera/32/6969_2.png) [@sebaherrera](https://discuss.elastic.co/u/sebaherrera)\
**Post date:** [November 16, 2015, 5:47am UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638/4 "2015-11-16T05:47:05Z")

</div>

correct me please if Im wrong. the idea would be to create index a document providing an id with my query params. if the cache hits that query params retrieves body json fields information like the following example:

$params = [  
'index' =\> 'my\_index',  
'type' =\> 'my\_type',  
'id' =\> 'query-params',  
'timestamp' =\> strtotime("-1d"),  
'body' =\> ['testField' =\> 'abc', 'aspecthistograms' =\> 'abc', 'categoryhistograms' =\> 'abc']  
];

$response = $client-\>index($params);

etc...

thanks in advance. brgds!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 16, 2015, 9:45am UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638/5 "2015-11-16T09:45:14Z")

</div>

Basically, yes.

You could do smart things like use an md5 hash of the query as the ID, then you can do things like routing - [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index\_.html#index-routing](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-routing)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:38pm UTC](https://discuss.elastic.co/t/its-a-possibility-to-cache-webservice-responses-using-key-value/34638/6 "2017-07-05T23:38:15Z")

</div>


