UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'BDya9Gy41hEdfi1roTtcYA2FQaJaLEWX1D5paB7JpL4=' 
WHERE 
  key_id = '51249d29b8a1e40abcafca826ed67776fd68cee49dff3905c1eb733c644cbbea' 
  AND (
    token = 'BDya9Gy41hEdfi1roTtcYA2FQaJaLEWX1D5paB7JpL4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039