UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'AE8cn7AiewJuBRhChmyNbZhIpKfijGa7SK42u8z+oSk=' 
WHERE 
  key_id = '584ab84f3a1f00761f7c88546e745c256045e8b1a6e4fbca85473767f0234755' 
  AND (
    token = 'AE8cn7AiewJuBRhChmyNbZhIpKfijGa7SK42u8z+oSk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00033