Check if a key exists in Memcache

前端 未结 11 2315
无人共我
无人共我 2021-02-12 15:17

How do I check in PHP if a value is stored in Memcache without fetching it? I don\'t like fetching it because the values I have set are all 1MB in size and after I fetch it, I h

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-12 15:35

    This makes no sense from Memcached perspective. If you want to avoid the slow datasource (by a scheduled job, I presume?), save the data to a faster but still stable datasource (e.g. a file) in your scheduled job. When you need the data, try to read from Memcached first, and if that fails read the file and save it into Memcached.

    Memcached cannot give you a good answer, as pakore have already answered. The architecture is not meant to be a stable datasource.

提交回复
热议问题