Its a possibility to Cache Webservice Responses using Key Value?


(Sebastian Herrera) #1

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.

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.


(Mark Walkom) #2

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 for something that you are comfortable with!


(Sebastian Herrera) #3

thank you Mark, reading the php client now..


(Sebastian Herrera) #4

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!


(Mark Walkom) #5

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


(system) #6