UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'AP39vmwagoViTvSUAWz96W02dG6JqdDenn99s2zOWvQ=' 
WHERE 
  key_id = 'c5b8a045f2b29647d244d98ec4ae9537d1cb10082b64e1944e539e5bde8385d7' 
  AND (
    token = 'AP39vmwagoViTvSUAWz96W02dG6JqdDenn99s2zOWvQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00049