UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HHSf3aM29n/W7E5vg3za/KpfdAd2rP8NZHuIlMpFFiw=' 
WHERE 
  key_id = '790c9875ff765fcf182c3f123685ca8bdeda18e245cf6cc4879ed9c9e5ee2433' 
  AND (
    token = 'HHSf3aM29n/W7E5vg3za/KpfdAd2rP8NZHuIlMpFFiw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034