UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Cs1PG/boR0YX5N5pOvj99TbzATi6KbFMVe2M0jsdtDc=' 
WHERE 
  key_id = '39b479f7257630e1f847a26e6a9b52e8d2c51e98e4693f3d9a7c78dfd230594d' 
  AND (
    token = 'Cs1PG/boR0YX5N5pOvj99TbzATi6KbFMVe2M0jsdtDc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038