UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'p51++UlzffChhQbxmTWXz91MrTiyhLYIgHMsQLnh5Zo=' 
WHERE 
  key_id = '4bc3e461da5afe3fd393d26e2199039e89720caec05014e501e068e634bd548d' 
  AND (
    token = 'p51++UlzffChhQbxmTWXz91MrTiyhLYIgHMsQLnh5Zo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037