UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'gJ82sMRe+qbx6PQH1TgnYAnH6MgTVnUoDPuJj49RTcA=' 
WHERE 
  key_id = 'b801bd05ebe5418b3d71656b85132ca71af2b6d84a0a799550a41860879a5464' 
  AND (
    token = 'gJ82sMRe+qbx6PQH1TgnYAnH6MgTVnUoDPuJj49RTcA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026