UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ptHlAjp6+XdIzWR6lVtRhy3uoLnWKbopWqvXAUk2PHw=' 
WHERE 
  key_id = '1a13d5afa47fe4d230f0729fc472b80db664f1439857716076af5174b0858738' 
  AND (
    token = 'ptHlAjp6+XdIzWR6lVtRhy3uoLnWKbopWqvXAUk2PHw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039