UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'pUEhC1wBlQX/3rPM6AgSuMtnkva2EkgdUWw+WwKsABo=' 
WHERE 
  key_id = '86767aeb0a98d245d6795d8818b70b514490cb687c60d474d88b865e56863317' 
  AND (
    token = 'pUEhC1wBlQX/3rPM6AgSuMtnkva2EkgdUWw+WwKsABo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00019