hash value, checksum or what

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

hash value, checksum or what

Jolle Carlestam-2
I regards to an API I’m developing for a client a request has been made that the API in the first round should send only ids and a hash value.
Wit the idea of the hash to be that it would be easier for the client server to examine and compare with previous results and ask only for those records in the next round.

This is new territory for me. Any ideas how to do this using Lasso?


Environment
Lasso 9.3.X
Data from Mysql

Data does not change often. It’s listings and details about events.

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: hash value, checksum or what

Brad Lindsay
I’m not entirely clear what they want, but it sounds like this:

- one endpoint that returns a JSON array whose contents are the full
objects for the resources

- one endpoint that returns a JSON array whose contents are objects
that have the ID and a hash generated from the full JSON object.

First, I would stress the importance of having one source generate the
hash so that you don’t have to try and fix discrepancies in JSON
encoders. This may mean that the first endpoint might have to add a
“hash” attribute and value if they want to be able to hit that first
and get the hashes with the data.

Since you’re not doing this for security but essentially just for
caching, I would use the fastest hashing method I could find which
will probably be either MD5 or Lasso’s [string->hash] method.


// Untested examples
//
// Generate array of objects with hash attribute
with my_map in #array_of_maps do {
  local(hash) = encode_json(#my_map)->hash
  #my_map->insert("_hash"=#hash)
}
encode_json(#array_of_maps)

// Generate array of objects with just ID and hash attributes
local(new_array)
with my_map in #array_of_maps do {
  local(hash) = encode_json(#my_map)->hash
  #new_array->insert(map("id"=#my_map->find('id'), "hash"=#hash))
}
encode_json(#new_array)


HTH,
Brad



On February 22, 2017 at 8:25:39 AM, Jolle Carlestam ([hidden email]) wrote:

> I regards to an API I’m developing for a client a request has been made that the API in the
> first round should send only ids and a hash value.
> Wit the idea of the hash to be that it would be easier for the client server to examine and
> compare with previous results and ask only for those records in the next round.
>
> This is new territory for me. Any ideas how to do this using Lasso?
>
>
> Environment
> Lasso 9.3.X
> Data from Mysql
>
> Data does not change often. It’s listings and details about events.
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to:
> Send administrative queries to

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>