UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'we3Dn+zRa4lH0j70tBzyHP53xMjb6U94NEmrDrzGdiE=' 
WHERE 
  key_id = '396eae3807e46baf31deb81f24771db2a71d7068b7d0a61a88c13514cacabd6e' 
  AND (
    token = 'we3Dn+zRa4lH0j70tBzyHP53xMjb6U94NEmrDrzGdiE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029