UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'S6BaYMlUYLoUGgFxS+Lg1rCaODl/oU2zSlsgcAQ6j40=' 
WHERE 
  key_id = '09cdf7a0857ea7c6b63a6de4dbd355e6bd536efbe8616b5fccffa8d95503089d' 
  AND (
    token = 'S6BaYMlUYLoUGgFxS+Lg1rCaODl/oU2zSlsgcAQ6j40=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028