doukuang1897
doukuang1897
2017-07-13 15:06

合并两个发布请求中的数据

已采纳

I have a Rest API that gets the POST requests, data and images comes in two different requests.

/v1/photo # multipart/form-data
/v1/data # json

I'm trying to merge values into Redis

# Save photo
HSET photo:1.jpg file_name 9f7a6775-3815-4d20-affa-e81bc9c4293b
SADD have:uuid photo:1.jpg
HSET photo:2.jpg file_name fcb7db2d-159e-4d0e-b884-ca455bd6f4a5
SADD have:uuid photo:2.jpg

# Save data
HSET photo:1.jpg data JSONsring
SADD have:data photo:1.jpg
HSET photo:2.jpg data JSONsring
SADD have:data photo:2.jpg

Now I need to get all the combined data (In order to save them to another database). I can use sinter to get keys.

SINTER have:uuid have:data

But i need JSON and UUID.

How to make it as quickly and with the minimum spent resources?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • donglv9813 donglv9813 4年前

    For the sake of ensuring this has a marked answer, I'll take the advice of @reticentroot and format the comment into an answer.

    It would be more idiomatic for your POST endpoint to accept the request regardless of whether a corresponding /v1/photo or /v1/data entry has been created. The process that's interfacing with these pieces of data could easily check whether it has both pieces of data, and act accordingly.

    点赞 评论 复制链接分享