UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'nk8xTuE8bhGh9ATKWQZDUDbxW42bkY06wep74Bgt+/Q=' 
WHERE 
  key_id = 'ed714e7cc06bb809b517eb6adaaace09c66570474601480600accd55fdabc617' 
  AND (
    token = 'nk8xTuE8bhGh9ATKWQZDUDbxW42bkY06wep74Bgt+/Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038